ip_forward不适用于tcp

时间:2015-11-16 09:30:52

标签: linux iptables

我有一个带有2个接口的linux盒子,wlan0和wlan1。 wlan0连接到子网192.168.43.x的外部wlan AP。在wlan1上,softap在子网192.168.60.x上运行。

我已经运行以下命令来启动nat和ip_forward:

iptables -F
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t nat -F
iptables -t mangle -F

iptables -A INPUT -j ACCEPT
iptables -A OUTPUT -j ACCEPT
iptables -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

另一台pc e6220连接到192.168.60.x softap。我想将pc的流量转发到外部网络192.168.43.x。

网络图:

外部AP(192.168.43.1)< ~~~> {wlan0(192.168.43.2),< - forward - > wlan1上的内部AP(192.168.60.1)}< ~~~> e6220(192.168.60.46)

在pc上添加路由后,icmp和udp工作正常,两者都可以达到192.168.43.1,但tcp不起作用!

userg@e6220:~ $ ping 192.168.43.1
PING 192.168.43.1 (192.168.43.1) 56(84) bytes of data.
64 bytes from 192.168.43.1: icmp_seq=1 ttl=63 time=9.74 ms
64 bytes from 192.168.43.1: icmp_seq=2 ttl=63 time=9.57 ms
^C

user@e6220:~ $ telnet 192.168.43.1
Trying 192.168.43.1...
telnet: Unable to connect to remote host: Network is unreachable

在linux框上捕获wlan1:

17:10:57.579994 IP 192.168.60.46.56412 > 192.168.43.1.telnet: Flags [S], seq     1764532258, win 29200, options [mss 1460,sackOK,TS val 2283575078 ecr 0,nop,wscale 7], length 0
17:10:57.580075 IP 192.168.60.1 > 192.168.60.46: ICMP net 192.168.43.1 unreachable, length 68

在wlan0上没有看到数据包。

奇怪的内核说无法访问,但UDP工作正常。

// route -n output
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.43.1    0.0.0.0         UG    0      0        0 wlan0
192.168.43.0    0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.60.0    0.0.0.0         255.255.255.0   U     0      0        0 wlan1

我认为这可能是特定于内核版本的。在Linux 3.4.x上,tcp和udp都很好。在Linux 3.10.61上可以看到此问题。我想知道是否有任何方法可以解决它,内核配置或iptables命令。谢谢!

0 个答案:

没有答案