|
[color=rgba(0, 0, 0, 0.75)]需求:将访问211.211.1.69的数据包通过em2发送到172.24.32.6,实现内网访问211.211.1.69。
- # 网络基本信息
- [root@apprz network-scripts]# route
- Kernel IP routing table
- Destination Gateway Genmask Flags Metric Ref Use Iface
- 172.24.32.4 * 255.255.255.252 U 1 0 0 em2
- 192.168.9.0 * 255.255.255.0 U 1 0 0 em1
- default 192.168.9.254 0.0.0.0 UG 0 0 0 em1
- [root@nagios ~]# cat /etc/sysconfig/network-scripts/ifcfg-em2
- DEVICE=em2
- IPADDR=172.24.30.6
- NETMASK=255.255.255.252
- [root@nagios ~]# cat /etc/sysconfig/network-scripts/ifcfg-em1
- DEVICE=em1
- IPADDR=192.168.9.13
- NETMASK=255.255.255.0
- GATEWAY=192.168.9.254
复制代码 静态路由添加命令:
- route add –host 211.211.1.69 gw 172.24.32.6 dev em2
复制代码 [color=rgba(0, 0, 0, 0.75)]错误 -net 只能指定网段- [root@nagios ~]# route add -net 211.211.10.69 netmask 255.255.255.0 dev eth3
- route: netmask doesn't match route address
复制代码 [color=rgba(0, 0, 0, 0.75)]正确- [root@nagios ~]# route add -net 211.211.10.0 netmask 255.255.255.0 dev eth3
复制代码 [color=rgba(0, 0, 0, 0.75)]错误 -host 不用指定掩码- [root@nagios ~]# route add -host 211.211.1.69 netmask 255.255.255.0 gw 172.30.0.69
- route: netmask 000000ff doesn't make sense with host route
复制代码 [color=rgba(0, 0, 0, 0.75)]正确- [root@nagios ~]# route add –host 211.211.10.69 netmask 255.255.255.0 gw 172.24.30.5 dev em2
复制代码
|
|