Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides
https://forum.ivorde.com/

Changing default route in Linux Redhat/Debian
https://forum.ivorde.com/changing-default-route-in-linux-redhat-debian-t99.html
Page 1 of 1

Author:  debuser [ Fri Jun 11, 2010 10:56 am ]
Post subject:  Changing default route in Linux Redhat/Debian

When having IP aliases on one interface, by default, the kernel will choose the main IP as a source. Example:

Code:
server# ip a l bond1
3: bond1: <BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue
    link/ether 00:0e:0c:6f:25:a1 brd ff:ff:ff:ff:ff:ff
    inet 168.22.13.11/24 brd 172.22.11.255 scope global bond1
    inet 168.22.13.15/32 scope global bond1
server# ip ro get 10.1.1.1
10.1.1.1 via 168.22.13.254 dev bond1  src 168.22.13.11
    cache  mtu 1500 advmss 1460 hoplimit 64


Changing a route (in this case, default one)on a Linux systems with multiple IP addresses per interface can be done with following command:
Code:
server# ip ro change default via 168.22.13.254 src 168.22.13.15
server# ip ro get 10.1.1.1
10.1.1.1 via 168.22.13.254 dev bond1  src 168.22.13.15
    cache  mtu 1500 advmss 1460 hoplimit 64


Changing it back to previous state is the same, without the "src" part:
Code:
server# ip ro change default via 168.22.13.254 src 168.22.13.15

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/