HI,
I have used iptables to set up a specific DNS server for a device on my LAN. This can be useful for certain Internet TV services such as Netflix. Thought others may find this useful.
Telnet to the router and open Busybox shell:
$ telnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
VMG8324-B10A
Login: admin
Password:
> echo && bash
Check the current iptables listing for Prerouting:
~ # iptables -t nat -L PREROUTING
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere 224.0.0.0/4
REMOTE_MGMT all -- anywhere anywhere
WEB_REDIRECT all -- anywhere anywhere
CUSTOM_WEB_REDIRECT all -- anywhere anywhere
PORT_FORWARD all -- anywhere anywhere
DMZ all -- anywhere anywhere
IGMP_CHAIN all -- anywhere anywhere
OTHERS all -- anywhere anywhere
~ #
Add the rule to use specific dns server (replace <<>> ip adresses with those you wish to use:
~ # iptables -t nat -I PREROUTING -i br0 -s <<device IP>>/32 -p udp --dport 53 -j DNAT --to <<DNS Server IP>>
~ # iptables -t nat -I PREROUTING -i br0 -s <<device IP>>/32 -p tcp --dport 53 -j DNAT --to <<DNS Server IP>>
Check the updated iptables listing for Prerouting:
~ # iptables -t nat -L PREROUTING
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- <<device IP>> anywhere tcp dpt:domain to:<<DNS Server IP>>
DNAT udp -- <<device IP>> anywhere udp dpt:domain to:<<DNS Server IP>>
ACCEPT all -- anywhere 224.0.0.0/4
REMOTE_MGMT all -- anywhere anywhere
WEB_REDIRECT all -- anywhere anywhere
CUSTOM_WEB_REDIRECT all -- anywhere anywhere
PORT_FORWARD all -- anywhere anywhere
DMZ all -- anywhere anywhere
IGMP_CHAIN all -- anywhere anywhere
OTHERS all -- anywhere anywhere
These rules disappear on reboot, if anyone knows how these rules can be made persistent please post the method here.
Chris.