I receive UDP broadcast packets on wlan0
on my Raspberry Pi which I'd like to forward to my desktop for analysis via eth0
.
I'm running a modified WiFi firmware on a raspberrypi which sends UDP packets on wlan0
. I can capture them with tcpdump
on the raspberrypi:
root@raspberrypi:/home/pi# tcpdump -i wlan0 dst port 5500 -vv
tcpdump: listening on wlan0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
07:13:15.368931 IP (tos 0x0, ttl 1, id 1, offset 0, flags [none], proto UDP (17), length 1070)
10.10.10.10.5500 > 255.255.255.255.5500: [no cksum] UDP, length 1042
07:13:15.470352 IP (tos 0x0, ttl 1, id 1, offset 0, flags [none], proto UDP (17), length 1070)
10.10.10.10.5500 > 255.255.255.255.5500: [no cksum] UDP, length 1042
07:13:15.573735 IP (tos 0x0, ttl 1, id 1, offset 0, flags [none], proto UDP (17), length 1070)
10.10.10.10.5500 > 255.255.255.255.5500: [no cksum] UDP, length 1042
07:13:15.675052 IP (tos 0x0, ttl 1, id 1, offset 0, flags [none], proto UDP (17), length 1070)
As you can see they are UDP packets from 10.10.10.10:5500
destined to 255.255.255.255:5500
. To forward them, I've tried using netfilter:
table ip nexmoncsi {
chain PRERT {
type nat hook prerouting priority dstnat; policy accept;
ip saddr 10.10.10.10 ip daddr 255.255.255.255 udp sport 5500 udp dport 5500 dnat to IP-Desktop
}
chain POSTRT {
type nat hook postrouting priority srcnat; policy accept;
ip saddr 10.10.10.10 ip daddr 255.255.255.255 udp sport 5500 udp dport 5500 snat to IP-Raspberrypi
}
}
I've enabled forarding with sysctl
sysctl net.ipv4.ip_forward=1
sysctl net.ipv4.conf.eth0.forwarding=1
sysctl net.ipv4.conf.wlan0.forwarding=1
sysctl net.ipv4.conf.eth0.bc_forwarding=1
sysctl net.ipv4.conf.wlan0.bc_forwarding=1
I ran the same tcpdump
command on the desktop to get the packets, but there are none. tcpdump
on the pi still reports packets, which I'm guessing shouldn't happen if they're forwarded.
I've verified that the matches are correct and that netfilter sees the packets with count
in a filter chain. Incidentally the count in the filter chain stops working when the preroute and postroute chains are added.
ufw
is disabled on the desktop, and nft ruleset on it has empty chains with no rules. What could be making the forwarding not work?