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?

1 Answer 1

4

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.

4
  • 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, 2019 at 6:33
  • No, they are not persisted during reboot unless written in a configuration file or a script.
    – Khaled
    Jan 8, 2019 at 8:13
  • What would be the persistent way to execute these changes?
    – Noam
    Jan 10, 2019 at 9:18
  • It helped me to implement IP rotation in Postfix email server Feb 10, 2022 at 11:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .