I have two DNS/DHCP Ubuntu servers for my house. UFW on these servers needs port 53 commands. I only want my IPv4 and IPv6 subnets allowed into these DNS servers. UFW allows traffic out to the internet for DNS port 53. These rules allow only my subnets to go into the DNS servers.
#DNS sudo ufw allow from 192.168.1.0/24 to any port 53 sudo ufw allow from 2600:1702:980:25ef:0:0:0:0/64 to any port 53
#DHCP sudo ufw allow proto udp to any port 67 from 192.168.1.0/24 sudo ufw allow proto udp to any port 68 from 192.168.1.0/24 sudo ufw allow proto udp to any port 67 from 2600:1702:980:25ef:0:0:0:0/64 sudo ufw allow proto udp to any port 68 from 2600:1702:980:25ef:0:0:0:0/64