On Ubuntu 22.04 I am trying to render the incoming traffic of a certain port to another ip address. I have redirected several TCP ports with this command and they all work correctly: iptables -t nat -A PREROUTING -d 82.xxx.xx.xxx -p tcp --dport 8123 -j DNAT --to-destination However, when I try to redirect a UDP port, I see it closed from the outside. I use this command. What am I doing wrong?

iptables -t nat -A PREROUTING -d -p udp --dport 1883 -j DNAT --to-destination


  • If it's about WireGuard state it. I'll assume it is. Does WireGuard answer anything at all that you can see using tcpdump? Is the local system or a remote system (including VM or container) with the Ubuntu system acting as router? With UDP (instead of TCP) this does matter when the iptables system is not routing but is the end system: multi-homing routing issues can happen, specific to UDP. Also, in addition to previous questions, you should provide the whole ruleset using iptables-save -c (rather than iptables -L).
    – A.B
    Commented Feb 19, 2023 at 11:47

1 Answer 1


There are a few potential issues that could be causing your UDP port redirection to fail:

1- Make sure that your firewall is not blocking UDP traffic to the specified port. You can use the "ufw" utility to check your firewall settings and make sure that the port is allowed.

2- Check that your NAT rules are configured correctly. You should verify that the "PREROUTING" chain is being used to redirect incoming traffic, and that the "DNAT" rule is correctly specifying the destination IP address and port.

3- If you are using a network address translation (NAT) device, such as a router, to forward traffic to your Ubuntu machine, make sure that it is configured to forward UDP traffic to the correct IP address and port.

You can also try running a network packet capture tool like Wireshark to see if the incoming traffic is actually being redirected to the correct IP address and port. This may help you identify any additional issues that are preventing the traffic from reaching your Ubuntu machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .