Im trying to block all websites but one with DD-WRT on a Linksys router. I am currently using this script:

iptables -I FORWARD 1 -p tcp -d dd-wrt.com --dport 80 -j ACCEPT
iptables -I FORWARD 2 -p tcp --dport 80 -j DROP

But this does not seem to work, as it is blocking access via HTTP to dd-wrt.com as well. Any help?


Make sure you're allowing the return traffic, at the moment it looks like traffic is probably getting out, but responses are not being allowed:

iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
| improve this answer | |
  • I tried adding that to the end of my script. And i cant get it work now either. Here is the whole script. pastebin.com/6jjwws9y – Kaizokupuffball May 8 '12 at 8:56
  • Are you talking about allowing the router itself to talk to the web page or machines behind it? Because if you mean machines behind it, there's no rule to allow the packets that establish the connection in the first place into the router. – David Schwartz May 8 '12 at 9:07
  • Im talking about letting the computers have access to onle a few websites (see the IP adresses) via port 80 & 443. The computers should NOT have access to e.g. google.com or bing.com – Kaizokupuffball May 8 '12 at 9:10
  • In the question you've used the FORWARD chain, where as in your paste you're using the INPUT chain - you need to use the FORWARD chain for routed packets, additionally your pasted configuration has all the rules specifying source addresses, not destination addresses. – James Yale May 8 '12 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.