How to configure ufw to redirect DNS 53 port traffic to another IP (DNS server)

I want to redirect all TCP/UDP port 53 traffic from one server (ufw firewall host) to another IP address.
I have the ufw firewall. How can I configure my ufw to redirect TCP and UDP 53 port traffic to internal DNS server hosted at LAN?

Router -> UFW -> LAN
--
1. UFW server 1.2.3.4 public IPv4/IPv6
2. LAN DNS server is at 10.83.200.100 TCP/UDP port 53
--

How do I do it?

  1. Edit the /etc/sysctl.conf file and set net.ipv4.ip_forward=1
  2. Save and close the file.
  3. Reload changes by running the sudo sysctl -p
  4. Edit the /etc/ufw/before.rules file
  5. At the top of the file add:
*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -i eth0 -d 1.2.3.4   -p tcp --dport 53 -j  DNAT --to-destination 10.83.200.100:53
-A PREROUTING -i eth0 -d 1.2.3.4   -p udp --dport 53 -j  DNAT --to-destination 10.83.200.100:53
-A POSTROUTING -s 10.83.200.0/24 ! -d 10.83.200.0/24 -j MASQUERADE
COMMIT
  1. Save and close the file.
  2. Restart the firewall: sudo systemctl restart ufw
  3. Verify it dig example.com @1.2.3.4

See:

And: