I wanted to expose an IPcam to Internet using WireGuard tunnel, diagram looks like this:
Client --β> ServerA -β-(wireguard)---> ServerB ---(LAN)--β> Cam I've set proper DNAT and SNAT rules; but only TCP works, UDP doesn't. π€
ServerA rules:
table inet filter { chain prerouting { type nat hook prerouting priority 0; policy accept; ##IPcam - forwards to ServerB iifname eth0 tcp dport 5541 dnat ip to 192.168.2.2:5541 iifname eth0 udp dport 5541 dnat ip to 192.168.2.2:5541 } chain postrouting { type nat hook postrouting priority 0; policy accept; oifname eth0 masquerade ##IPcam oifname wg2 ip daddr 192.168.2.2 tcp dport 5541 snat to 192.168.2.1 oifname wg2 ip daddr 192.168.2.2 udp dport 5541 snat to 192.168.2.1 } } ServerB rules:
table inet filter { chain prerouting { type nat hook prerouting priority 0; policy accept; ##IPcam - Forwards to actual cam iifname wg0 tcp dport 5541 dnat ip to 192.168.5.63:554 iifname wg0 udp dport 5541 dnat ip to 192.168.5.63:554 } chain postrouting { type nat hook postrouting priority 0; policy accept; oifname eth0 masquerade } } When streaming using TCP it works perfectly, but UDP does not work.
// tcp works mpv --rtsp-transport=tcp rtsp://serverA:5541/Streaming/Channels/1 // udp not work mpv --rtsp-transport=udp rtsp://serverA:5541/Streaming/Channels/1 Even though rules for UDP and TCP are same, why TCP work but UDP fails?
ChatGPT spitting out garbage, any help would be highly appreciated. π