How to set route table source address permanent

Hello every,

I want to set the outbound ip address from the route table.
I can use this command to achieve it, but may I ask how can I do it permanent even I reboot the server? Thank you

ip route change default via [gateway ip] src [outbound ip]

For "src [outbound ip] " part, shout I just do it in following way?


cat /etc/sysconfig/network/ifroute-eth0
[gatway ip] - 255.255.255.255 eth0
default [gatway ip] - eth0 src [outbound ip]

thank you :wink:

Yes, it works both for IPv4 and IPv6.

Reads like you have this working now? In any case, the pertinent information can be found here…

man ifroute

This is a very old question that people have run into since forever.

If you were on MWWindows, there is a command to make the custom routing entry persistent.
That doesn’t exist in Linux (unless someone decides to make it happen),

So,
The one very popular way which I’ve personally adopted is to simply add your command to /etc/sysctl.conf.
What this does is whenever you boot, any commands in this file are executed to re-make or re-apply custom configurations.
Read the contents of this file to see not only what is in this file but also the child sysctl files which also might contain settings.