Raspberry pi 只能从两个子网Rpi 4 buster之间的一个方向接收ping

Raspberry pi 只能从两个子网Rpi 4 buster之间的一个方向接收ping,raspberry-pi,router,ping,iptables,Raspberry Pi,Router,Ping,Iptables,我有一个典型的配置,其中Rpi充当两个子网之间的路由器。一个子网连接到Rpi eth0,现在有笔记本电脑直接连接(总有一天会有一个ip摄像头)。Rpi通过wlan0连接到无线路由器以获得互联网连接。 网络上有几条说明可以让它工作,而且几乎可以工作。我可以从连接到Rpi的笔记本电脑ping连接到我的无线路由器(但不是我的无线路由器!?)的设备。我在连接到Rpi的笔记本电脑上有互联网连接。但问题是,我不能从我的无线路由器的子网ping我的笔记本电脑(连接到Rpi)。是的,这和我的困惑有关 以下是一

我有一个典型的配置,其中Rpi充当两个子网之间的路由器。一个子网连接到Rpi eth0,现在有笔记本电脑直接连接(总有一天会有一个ip摄像头)。Rpi通过wlan0连接到无线路由器以获得互联网连接。

网络上有几条说明可以让它工作,而且几乎可以工作。我可以从连接到Rpi的笔记本电脑ping连接到我的无线路由器(但不是我的无线路由器!?)的设备。我在连接到Rpi的笔记本电脑上有互联网连接。但问题是,我不能从我的无线路由器的子网ping我的笔记本电脑(连接到Rpi)。是的,这和我的困惑有关

以下是一些数据:

我已经在sysctl.conf文件中设置了net.ipv4.ip_forward=1

我已完成以下设置:

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT

sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
IPtables如下所示:

pi@raspberrypi:~ $ sudo iptables -L -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
  296  191K ACCEPT     all  --  wlan0  eth0    anywhere             anywhere             state RELATED,ESTABLISHED
   37 14316 ACCEPT     all  --  eth0   wlan0   anywhere             anywhere

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.3.1     0.0.0.0         UG    100    0        0 wlan0
default         192.168.3.1     0.0.0.0         UG    202    0        0 eth0
10.10.0.0       0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U     100    0        0 wlan0
192.168.3.1     0.0.0.0         255.255.255.255 UH    202    0        0 eth0
路由选项卡如下所示:

pi@raspberrypi:~ $ sudo iptables -L -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
  296  191K ACCEPT     all  --  wlan0  eth0    anywhere             anywhere             state RELATED,ESTABLISHED
   37 14316 ACCEPT     all  --  eth0   wlan0   anywhere             anywhere

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.3.1     0.0.0.0         UG    100    0        0 wlan0
default         192.168.3.1     0.0.0.0         UG    202    0        0 eth0
10.10.0.0       0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U     100    0        0 wlan0
192.168.3.1     0.0.0.0         255.255.255.255 UH    202    0        0 eth0

任何其他有用的信息?

在无线路由器路由表中,您应该将10.10.0.0/24的流量转发到连接到第二个子网的接口,将192.3.0.0/24的流量转发到连接到Rpi的接口,并将其他流量转发到连接到internet的接口。 您还应该有一个到子网1的路由表,其中Rpi作为网关,如下所示:

pi@raspberrypi:~ $ sudo iptables -L -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
  296  191K ACCEPT     all  --  wlan0  eth0    anywhere             anywhere             state RELATED,ESTABLISHED
   37 14316 ACCEPT     all  --  eth0   wlan0   anywhere             anywhere

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.3.1     0.0.0.0         UG    100    0        0 wlan0
default         192.168.3.1     0.0.0.0         UG    202    0        0 eth0
10.10.0.0       0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U     100    0        0 wlan0
192.168.3.1     0.0.0.0         255.255.255.255 UH    202    0        0 eth0
目标网关Genmask
192.168.3.0 Rpi@IP 255.255.255.0