Difference between revisions of "Firewall"
From Organic Design wiki
(add an example pinhole) |
|||
Line 26: | Line 26: | ||
# Dont forward from the outside to the inside. | # Dont forward from the outside to the inside. | ||
iptables -A FORWARD -i eth0 -o eth0 -j REJECT | iptables -A FORWARD -i eth0 -o eth0 -j REJECT | ||
+ | |||
+ | # Example pinhole: forward packets on port 5900 to 192.168.1.100 | ||
+ | iptables -A FORWARD -i eth0 -o eth1 -p tcp --dport 5900 -j ACCEPT | ||
+ | iptables -A PREROUTING -t nat -p tcp --dport 5900 -j DNAT --to-destination 192.168.1.100 | ||
# Enable routing. | # Enable routing. |
Revision as of 05:13, 25 May 2009
This is a basic firewall which works for most Linux distro's. It's based on the Setting up a simple Debian gateway article from debian-administration.org and assumes eth0 to be the external WAN interface and eth1 the internal LAN interface. On Debian based machines, save this script as /etc/network/if-up.d/00-firewall and it will execute whenever the networking starts up.