设置linux路由

前端之家收集整理的这篇文章主要介绍了设置linux路由前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试设置的系统具有IP地址172.31.2.1.它的默认网关是172.31.254.1.这很好,我可以到达网关允许我去的任何东西(172.31.0.0/16 149.244.178.0/24).

在149.244.178.1还有另一个网关,它允许我在149.244.0.0中获得任何内容,我正在尝试将其添加到表中,以便我可以访问149.244.64.250.

这是我的路由表目前的样子:

  1. Kernel IP Routing table
  2. Destination Gateway Genmask Flags Metric Ref Use Iface
  3. 172.31.0.0 * 255.255.0.0 U 0 0 0 eth0
  4. 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
  5. default 172.31.254.1 0.0.0.0 UG 0 0 0 eth0

route add 149.244.0.0/16 gw 1​​49.244.178.1给出错误

  1. route: netmask 0000ffff doesn't make sense with host route.

route add -net 149.244.0.0/16 dev eth0将路由表更改为:

  1. Kernel IP Routing table
  2. Destination Gateway Genmask Flags Metric Ref Use Iface
  3. 172.31.0.0 * 255.255.0.0 U 0 0 0 eth0
  4. 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
  5. 149.244.0.0 * 255.255.0.0 U 0 0 0 eth0
  6. default 172.31.254.1 0.0.0.0 UG 0 0 0 eth0

但是,尝试添加网关仍然给我同样的错误.对不起,如果听起来很复杂,任何帮助表示赞赏!

解决方法

149.x.x.x主机不在您的本地子网上,因此您的计算机无法联系它.子网与该子网之间的路由器应该同时具有149.x和172.x地址(希望在两个不同的NIC上),它将在两个子网之间路由.

猜你在找的Linux相关文章