On my CentOS server I have configured 7 ip addresses.

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

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

[root@db01 network-scripts]# ip route show dev eth0  scope link dev eth0  proto kernel  scope link  src dev eth0  scope link  metric 1002
default via dev eth0

How can I change my IP address for outbound connections to


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

ip route replace default via dev eth0 src

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

ip route replace dev eth0 src

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.