1

On my CentOS server I have configured 7 ip addresses.

The default IP address is 87.233.82.98 en this address should be used for outbound connections. However the 87.233.82.99 address is used for outbound connections.

The .99 address is also mentioned in the ip route table.

[root@db01 network-scripts]# ip route show
87.233.82.98 dev eth0  scope link
87.233.82.0/24 dev eth0  proto kernel  scope link  src 87.233.82.99
169.254.0.0/16 dev eth0  scope link  metric 1002
default via 87.233.82.97 dev eth0

How can I change my IP address for outbound connections to 87.233.82.98?

3

You can change the source IP address used by default for outgoing connections using a command like the following:

ip route replace default via 87.233.82.97 dev eth0 src 87.233.82.98

Similarly, you can do the same to change source IP when contacting IPs within the same subnet using a command like:

ip route replace 87.233.82.0/24 dev eth0 src 87.233.82.98

You can see man ip-route for available options.

  • Is modifying the configuration via these commands persisted across server restarts? Or is it similar to "ip a add" commands which are only valid until the next restart? – Noam Jan 8 at 6:33
  • No, they are not persisted during reboot unless written in a configuration file or a script. – Khaled Jan 8 at 8:13
  • What would be the persistent way to execute these changes? – Noam Jan 10 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.