Image

Knowledge base → Changing the default IP address for outgoing traffic

[Virtual servers]
Date of publication: 07.02.2024

By default, Linux uses 1 IP address from each subnet for outgoing traffic. For example, you use several different subnets on one server and for each subnet Linux assigns 1 default IP address from which outgoing connections will occur.

1. View all subnets

ip route list

default dev venet0 scope link
123.123.123.0/24 dev venet0 proto kernel scope link src 123.123.123.101
123.123.124.0/24 dev venet0 proto kernel scope link src 123.123.124.145

In this example, for all IP addresses from the subnet 123.123.123.x, the IP address 123.123.123.101 will be used for all outgoing connections

And for all IP addresses from the subnet 123.123.124.x - IP address 123.123.124.145

2. Changing the IP address for outgoing connections

ip route change default via 123.123.123.1 src 123.123.123.200

Now, instead of the ip address 123.123.123.101, ip 123.123.123.200 will be used for the subnet 123.123.123.x

All IP addresses with which settings are made must be entered on the server.

3. View available IP addresses

To view all IP addresses available to the server, use the command:

apt install net-tools
ifconfig




No Comments Yet