Cannot add route SIOCADDRT: Network is unreachable
12,917
A gateway address must be reachable on a locally connected network for a static route to be useable. 10.251.x.x is not local to 10.250.0.0/16
Try something like this:
assuming 10.251.10.127 is reachable on the 10.250.1.46 interface,
ip route add -host 10.251.10.127 dev eth1
ip route add 10.20.0.0/16 via 10.251.10.127
Related videos on Youtube
Author by
user2133558
Updated on September 18, 2022Comments
-
user2133558 over 1 year
Hi so i want to add a route to add a route to docker container network (10.20.0.0/16) via host 10.251.10.127. Before adding the route i ping the host 10.251.10.127 and it's reachable. But then i do
sudo route add -net 10.20.0.0/16 gw 10.251.10.127
and i get
SIOCADDRT: Network is unreachable
This is my configuration
ifconfig docker0 Link encap:Ethernet HWaddr 02:42:48:4c:40:16 inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) eth0 Link encap:Ethernet HWaddr ec:b1:d7:56:9d:88 inet addr:192.168.108.155 Bcast:192.168.109.255 Mask:255.255.254.0 inet6 addr: fe80::f784:a7df:5e4e:ce2f/64 Scope:Link inet6 addr: 2620:2c:40c0:c00:afef:c210:1878:1e12/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:23681 errors:0 dropped:0 overruns:0 frame:0 TX packets:10525 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:15916466 (15.9 MB) TX bytes:1961427 (1.9 MB) Interrupt:20 Memory:f7d00000-f7d20000 eth1 Link encap:Ethernet HWaddr 68:05:ca:3e:0c:f3 inet addr:10.250.1.46 Bcast:10.250.255.255 Mask:255.255.0.0 inet6 addr: fe80::8f37:3338:32cf:ba39/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:18558 errors:0 dropped:0 overruns:0 frame:0 TX packets:289 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12158842 (12.1 MB) TX bytes:29883 (29.8 KB) Interrupt:19 Memory:f7cc0000-f7ce0000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:1973 errors:0 dropped:0 overruns:0 frame:0 TX packets:1973 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:193934 (193.9 KB) TX bytes:193934 (193.9 KB)
This is my route
route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.108.1 0.0.0.0 UG 100 0 0 eth0 0.0.0.0 10.250.0.1 0.0.0.0 UG 101 0 0 eth1 10.250.0.0 0.0.0.0 255.255.0.0 U 100 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 192.168.108.0 0.0.0.0 255.255.254.0 U 100 0 0 eth0
A couple more tables
ip route default via 192.168.108.1 dev eth0 proto static metric 100 default via 10.250.0.1 dev eth1 proto static metric 101 10.250.0.0/16 dev eth1 proto kernel scope link src 10.250.1.46 metric 100 169.254.0.0/16 dev eth0 scope link metric 1000 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 192.168.108.0/23 dev eth0 proto kernel scope link src 192.168.108.155 metric 100 ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 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 inet6 ::1/128 scope host 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 ec:b1:d7:56:9d:88 brd ff:ff:ff:ff:ff:ff inet 192.168.108.155/23 brd 192.168.109.255 scope global dynamic eth0 valid_lft 6539sec preferred_lft 6539sec inet6 2620:2c:40c0:c00:afef:c210:1878:1e12/64 scope global noprefixroute dynamic valid_lft 86395sec preferred_lft 14395sec inet6 fe80::f784:a7df:5e4e:ce2f/64 scope link valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 68:05:ca:3e:0c:f3 brd ff:ff:ff:ff:ff:ff inet 10.250.1.46/16 brd 10.250.255.255 scope global dynamic eth1 valid_lft 6540sec preferred_lft 6540sec inet6 fe80::8f37:3338:32cf:ba39/64 scope link valid_lft forever preferred_lft forever 4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:48:4c:40:16 brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 scope global docker0 valid_lft forever preferred_lft forever
-
A.B over 6 years10.251.10.127 isn't in the net 10.250.0.0/16 nor in any other net directly reachable. So you can't use it as a gateway. If you can't reach 10.20.0.0/16 you have to configure your default router instead (the one with IP 10.250.0.1). If it can't reach 10.251.10.127 directly either, then... you have to give more informations
-