Thursday, October 11, 2018

Adding static ip route when interface is down or Network is unreachable

Adding static route on interface fails when interface is down


root@r-118-JAY:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 0e:00:a9:fe:00:84 brd ff:ff:ff:ff:ff:ff
    inet 169.254.0.132/16 brd 169.254.255.255 scope global eth0
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 1e:00:7c:00:00:11 brd ff:ff:ff:ff:ff:ff
    inet 10.147.46.105/24 brd 10.147.46.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 1e:00:7c:00:00:22 brd ff:ff:ff:ff:ff:ff
    inet 10.147.52.202/24 brd 10.147.52.255 scope global eth2
       valid_lft forever preferred_lft forever
root@r-118-JAY:~#
root@r-118-JAY:~# ip route show table Table_eth2
throw 10.147.46.0/24  proto static
throw 10.147.70.0/24  proto static
throw 10.147.80.0/24
throw 10.147.81.0/24
root@r-118-JAY:~# ip route show table static_route
root@r-118-JAY:~#
root@r-118-JAY:~#  ip route add throw 10.147.81.0/24 table static_route
ip route throw on static_route table is success but below route add fails.
root@r-118-JAY:~# ip route add 10.147.70.0/24 via 10.147.52.1 table static_route
RTNETLINK answers: Network is unreachable


This route add is failing because ip interface eth2 (10.147.52.0/24) subnet is down. Here the route using via 10.147.52.1 which is not reachable now. Due to this the route add is failing.
 
root@r-118-JAY:~#
root@r-118-JAY:~# ip route show table static_route
throw 10.147.81.0/24
root@r-118-JAY:~#
 

No comments:

Post a Comment