I recommend rather installing proxy server ie. squid (http://www.squid-cache.or
Main Topics
Browse All TopicsI have many workstations on a network and I need some IP Table rules to block port 80 and 8080 of any websites, except for a few.
I will be configuring the IP Tables on each workstation.
All stations are using Ubuntu Jaunty.
It would also be helpful to know how to undo the IP Table rules if I need to.
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I recommend rather installing proxy server ie. squid (http://www.squid-cache.or
I am posting a full guide to how I accomplished this task to be used for anyone's reference.
I am using Ubuntu Jaunty.
The bash script may not work for other Linux flavors besides Debian, but it can be adapted if you know how.
Login as root (makes the process easier):
$ su -
$ mkdir /etc/custom_iptables
$ touch /etc/custom_iptables/iptab
# Create two chains
$ iptables -N HTTPX
$ iptables -N HTTPOK
# Append new rules to the chain
$ iptables -A OUTPUT -p tcp --dport 8080 -j HTTPX
$ iptables -A OUTPUT -p tcp --dport 80 -j HTTPX
$ iptables -A OUTPUT -p tcp --dport 443 -j HTTPX
# Generic table for HTTP & Proxy
$ iptables -A HTTPX -j HTTPOK
$ iptables -A HTTPX -j DROP
# These are the websites I want to allow access to
$ iptables -A HTTPOK -d mydomain.com -j ACCEPT
$ iptables -A HTTPOK -d myotherdomain.com -j ACCEPT
$ iptables -A HTTPOK -d xxx.xxx.xxx.xxx -j ACCEPT
# Export all the current IP Table rules to a file
$ iptables-save > /etc/custom_iptables/iptab
# Create a new file that will be used as a script for controlling the rules
$ touch /etc/init.d/custom_iptable
# Open the file with nano
$ nano /etc/init.d/custom_iptable
PASTE THE BASH SCRIPT BELOW INTO THE NANO EDITOR, THEN SAVE IT AND EXIT THE EDITOR.
# Make the script executable
$ chmod +x /etc/init.d/custom_iptable
# Add to boot runlevel (the period at the end is required)
$ update-rc.d custom_iptables start 37 S . stop 37 0 .
# Apply the rules by starting the script
$ /etc/init.d/custom_iptable
Log out of root user.
That's It. It works instantly.
The bash script will execute every time the computer is rebooted so it can apply the rules again.
You can also control the script with these commands anytime you want:
sudo /etc/init.d/custom_iptable
sudo /etc/init.d/custom_iptable
sudo /etc/init.d/custom_iptable
sudo /etc/init.d/custom_iptable
Hope this helps someone.
Business Accounts
Answer for Membership
by: nociPosted on 2009-09-30 at 06:40:51ID: 25458710
iptables -N HTTPX
iptables -N HTTPOK
# Select HTTP special cases
iptables -A OUTPUT -p tcp --dport 8080 -j HTTPX
iptables -A OUTPUT -p tcp --dport 80 -j HTTPX
iptables -A OUTPUT -p tcp --dport 443 -j HTTPX
# Generic table for HTTP & Proxy
iptables -A HTTPX -j HTTPOK
iptables -A HTTPX -j DROP # or reject if you are nice to them
# table with acceptable hosts.
iptables -A HTTPOK -d some.ip.address -j ACCEPT