大网数据广告活动
服务器运维问答

Unable to add a static route: SIOADDRT: Network is unreachable

· 52CE 我爱测

I've been bashing my head against a wall for a few days trying to figure this out: My ifconfig is: eth0 Link encap:Ethernet HWaddr 00:50:56:BB:XX:XX inet addr:192.168.36.132 Bcast:192.168.37.255 Mask:255.255.254.0 eth1 Link encap…

问题原文

原帖链接 · AnonPoster · CC BY-SA 3.0

I've been bashing my head against a wall for a few days trying to figure this out: My ifconfig is:

eth0      Link encap:Ethernet  HWaddr 00:50:56:BB:XX:XX
          inet addr:192.168.36.132  Bcast:192.168.37.255  Mask:255.255.254.0

eth1      Link encap:Ethernet  HWaddr 00:50:56:BB:XX:XX
          inet addr:116.xx.xx.xx    Bcast:116.xx.xx.xx    Mask:255.255.255.192

When I try and add a static route to go out of eth0, I get the following error:

servername-test:/ # route add -net 10.248.12.0 netmask 255.255.255.240 gw 192.168.36.254 dev eth0 
SIOCADDRT: Network is unreachable

My Default gateway is:

servername-test:~ # netstat -anr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
116.xx.xx.xx    0.0.0.0         255.255.255.192 U         0 0          0 eth1
192.168.238.0   192.168.36.254  255.255.255.0   UG        0 0          0 eth0
192.168.239.0   192.168.36.254  255.255.255.0   UG        0 0          0 eth0
192.168.36.0    192.168.36.254  255.255.254.0   UG        0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U         0 0          0 lo
0.0.0.0         116.xx.xx.xx    0.0.0.0         UG        0 0          0 eth1

ip route list output

116.66.240.64/26 dev eth1 proto kernel scope link src 116.xx.xx.xx 
192.168.238.0/24 via 192.168.36.254 dev eth0 
192.168.239.0/24 via 192.168.36.254 dev eth0 
192.168.36.0/23 via 192.168.36.254 dev eth0
169.254.0.0/16 dev eth0 scope link 
127.0.0.0/8 dev lo scope link 
default via 116.xx.xx.xx dev eth1

已采纳解答

原帖链接 · Matthew Ife · CC BY-SA 3.0

You have not declared 192.168.36.0/23 link local, despite the fact you have an address assigned for it, no link-local route appears to be listed in your routes.

192.168.36.0    192.168.36.254  255.255.254.0   UG        0 0          0 eth0
192.168.36.0/23 via 192.168.36.254 dev eth0

Instead its declared 192.168.36.0/23 should be passed to the gateway 192.168.36.254 which technically according to the rest of the routing table does not appear to be a neighbour (the kernel has no idea how to get to 192.168.36.254).

There should be no gateway assigned for 192.168.36.0/23 because according to your IP address 192.168.36.132/23 it is probably meant to be a a link-local range (neighbours directly responsive via ARP).

You should have an entry such as this instead:

192.168.36.0    0.0.0.0  255.255.254.0   U        0 0          0 eth0
192.168.36.0/23 dev eth0 scope link

To fix, you need to remove the gateway declaration for 192.168.36.0/23 and replace with an entry such as:

ip route add 192.168.36.0/23 dev eth0

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-03-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。