I have some chains that I create in iptables
iptables -N dns-requests
iptables -N wg0-filter
I then create a filter, to pass DNS traffic that are on Port 53.
iptables -A wg0-filter -p tcp --dport 53 -j dns-requests
iptables -A wg0-filter -p udp --dport 53 -j dns-requests
Then, I have some rules in the dns-requests
chain:
iptables -A dns-requests -d 208.67.220.220 -p tcp -j ACCEPT
iptables -A dns-requests -d 208.67.220.220 -p udp -j ACCEPT
iptables -A dns-requests -d 208.67.222.222 -p udp -j ACCEPT
iptables -A dns-requests -d 208.67.222.222 -p tcp -j ACCEPT
iptables -t nat -A dns-requests -p udp -j DNAT --to-destination 208.67.220.220:53
iptables -t nat -A dns-requests -p tcp -j DNAT --to-destination 208.67.222.222:53
With the above, I want to do the following:
- DNS requests that are sent to
208.67.220.220
or 208.67.222.222
should pass through
- DNS requests that are not sent to
208.67.220.220
or 208.67.222.222
should have DNAT
applied, so that the DNS
request goes to 208.67.220.220
I've tried quite a few different commands, but can't get it to work. The current error I have is:
iptables: No chain/target/match by that name.
When I run :
iptables -t nat -A dns-requests -p udp -j DNAT --to-destination 208.67.220.220:53
iptables -t nat -A dns-requests -p tcp -j DNAT --to-destination 208.67.222.222:53
Any ideas how to achieve what I'm after?