Changing the default output IP

If you want to change the outgoing IP address of your server use the following command.

Execute this command

# /sbin/ip route

The output should look something like this.

192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.53
169.254.0.0/16 dev eth1 scope link
default via 192.168.50.254 dev eth1

If no ‘src’ listed in ‘ip’ output for default route, then main IP on the interface is used for an outgoing connections. You can change it using:

/sbin/ip route change default via 192.168.50.254 dev eth1 src 192.168.50.100

Now when you execute

/sbin/ip route

You should see something like this

192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.53
169.254.0.0/16 dev eth1 scope link
default via 192.168.50.254 dev eth1 src 192.168.50.100

VERY IMPORTANT
Be sure of the ip address you enter here as you will make your server unreachable if you get it wrong.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.