- 论坛徽章:
- 0
|
本帖最后由 test_eaec01 于 2014-10-28 16:25 编辑
回复 12# abc3w
按照您提到的进行测试,这里吧10.10.10.2, gw 10.10.10.1 修改为: 172.16.1.123 gw 172.16.1.1/24:
192.168.10.2/24 gw 192.168.10.1
172.16.1.123/24 gw 172.16.1.1
路由设置如下:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
172.16.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 //eth0口IP主地址
172.16.12.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 //eth0:1口IP地址
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth3
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
测试到网关通讯:
192.168.10.2 ping 192.168.10.1 结果?, 通
192.168.10.1 ping 192.168.10.2 结果? 通
172.16.1.123 ping 172.16.1.1 结果? 通
172.16.1.1 ping 172.16.1.123 结果? 通
192.168.10.2 ping 172.16.1.123 不通,出现icmp: redirect 字样
在设备上抓包:- [quote]16:11:38.779579 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 64, id 1420, len 60)
- 16:11:38.779677 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 63, id 1420, len 60)
- 16:11:43.437310 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 64, id 1421, len 60)
- 16:11:43.437354 192.168.10.1 > 192.168.10.2: icmp: redirect 172.16.1.123 to host 172.16.1.123 for 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 63, id 1421, len 60) [tos 0xc0] (ttl 64, id 36801, len 88)
- 16:11:43.437377 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 63, id 1421, len 60)
- 16:11:48.437290 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 64, id 1422, len 60)
- 16:11:48.437328 192.168.10.1 > 192.168.10.2: icmp: redirect 172.16.1.123 to host 172.16.1.123 for 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 63, id 1422, len 60) [tos 0xc0] (ttl 64, id 36802, len 88)
- 16:11:48.437388 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 63, id 1422, len 60)
- 16:11:53.437322 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 64, id 1423, len 60)
- 16:11:53.437361 192.168.10.1 > 192.168.10.2: icmp: redirect 172.16.1.123 to host 172.16.1.123 for 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 63, id 1423, len 60) [tos 0xc0] (ttl 64, id 36803, len 88)
- 16:11:53.437382 192.168.10.2 > 172.16.1.123: icmp: echo request (ttl 63, id 1423, len 60)[/quote]
复制代码 172.16.1.123 ping 192.168.10.2 不通,出现icmp: redirect 字样
设备抓包如下:- tcpdump: listening on eth0
- 16:14:06.912273 172.16.1.123 > 192.168.10.2: icmp: echo request (ttl 64, id 17003, len 60)
- 16:14:11.566822 172.16.1.123 > 192.168.10.2: icmp: echo request (ttl 64, id 17012, len 60)
- 16:14:11.566882 172.16.1.1 > 172.16.1.123: icmp: redirect 192.168.10.2 to host 192.168.10.2 for 172.16.1.123 > 192.168.10.2: icmp: echo request (ttl 63, id 17012, len 60) [tos 0xc0] (ttl 64, id 18159, len 88)
- 16:14:16.566910 172.16.1.123 > 192.168.10.2: icmp: echo request (ttl 64, id 17027, len 60)
- 16:14:16.566948 172.16.1.1 > 172.16.1.123: icmp: redirect 192.168.10.2 to host 192.168.10.2 for 172.16.1.123 > 192.168.10.2: icmp: echo request (ttl 63, id 17027, len 60) [tos 0xc0] (ttl 64, id 18160, len 88)
复制代码 网关内部转发如下(rhel6.5及之前版本):
允许单网卡转发(默认iptables规则各系统不一样,确保可靠启用,插入这条规则):
#iptables -I FORWARD -i eth0 -o eth0 -j ACCEPT
规则已经添加
启动系统转发支持(重启前有效,永久生效更改/etc/sysctl.conf 里 net.ipv4.ip_forward = 1 ):
#echo 1 > /proc/sys/net/ipv4/ip_forward
转发规则已经开启
如交换机配置有vlan,交换机连接网关eth0的端口应配置为hybrid untag。
如还不通,贴出所有网络交换机配置及网关iptables规则。
交换机为2层傻瓜,无vlan其他配置。
iptables 规则如下:
[root@AllInOne ~]# iptables -vnL
Chain INPUT (policy ACCEPT 218K packets, 31M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 3023K packets, 1580M bytes)
pkts bytes target prot opt in out source destination
10 600 ACCEPT all -- eth0 eth0 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 257K packets, 44M bytes)
pkts bytes target prot opt in out source destination
iptables -t nat -vnL
Chain PREROUTING (policy ACCEPT 68957 packets, 4737K bytes)
pkts bytes target prot opt in out source destination
13161 820K ACCEPT udp -- eth0 * 0.0.0.0/0 202.106.0.20 udp dpt:53 //dns解析用
0 0 DNAT tcp -- eth1 * 0.0.0.0/0 192.168.1.222 tcp dpt:30001 to:172.16.12.2:80 //DNAT端口转发,无效
0 0 DNAT tcp -- eth1 * 0.0.0.0/0 192.168.1.222 tcp dpt:30002 to:172.16.12.2:22 //DNAT转发,无效。
256 15647 ACCEPT udp -- eth0 * 0.0.0.0/0 202.108.0.30 udp dpt:53 //DNS
14279 987K DNAT udp -- eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53 to:202.106.0.20
Chain POSTROUTING (policy ACCEPT 6117 packets, 371K bytes)
pkts bytes target prot opt in out source destination
84698 5222K SNAT all -- * eth1 0.0.0.0/0 0.0.0.0/0 to:192.168.1.222 //NAT规则,访问外网。
Chain OUTPUT (policy ACCEPT 6114 packets, 371K bytes)
无规则。 |
|