[Solved] Is this iptables example correct?
Posted: 29 Jan 2012, 19:46
Hi All,
I am reading up on iptables and I thought I got it until I saw a description and the iptables commands. The description is as follows
I do not understand how that can work, I tought that the iptables for doing what is described should look like the following.
My understanding is that
* the third line should block incoming TCP establishments from all ports and IP addresses
* the fourth line should allow outgoing TCP connections to WWW servers on the internet
* and that the fifth line should allow responses to on connections created by internal node
Source ports on a web browser is a random number higher than 1024 and the port of a web server is in most cases port 80.
Is the original example correct or am I?
Best Regards,
Morgan
I am reading up on iptables and I thought I got it until I saw a description and the iptables commands. The description is as follows
The iptables commands that is supposed to do this is in the exampleallow our users to be able to access WWW servers on the Internet, but to allow no other traffic to be passed
Code: Select all
iptables -F FORWARD
iptables -P FORWARD DROP
iptables -A FORWARD -m tcp -p tcp -s 0/0 --sport 80 -d 172.16.1.0/24 --syn -j DROP
iptables -A FORWARD -m tcp -p tcp -s 172.16.1.0/24 --sport 80 -d 0/0 -j ACCEPT
iptables -A FORWARD -m tcp -p tcp -d 172.16.1.0/24 --dport 80 -s 0/0 -j ACCEPT
Code: Select all
iptables -F FORWARD
iptables -P FORWARD DROP
iptables -A FORWARD -m tcp -p tcp -s 0/0 -d 172.16.1.0/24 --syn -j DROP
iptables -A FORWARD -m tcp -p tcp -s 172.16.1.0/24 -d 0/0 --dport 80 -j ACCEPT
iptables -A FORWARD -m tcp -p tcp -s 0/0 --sport 80 -d 172.16.1.0/24 -j ACCEPT
* the third line should block incoming TCP establishments from all ports and IP addresses
* the fourth line should allow outgoing TCP connections to WWW servers on the internet
* and that the fifth line should allow responses to on connections created by internal node
Source ports on a web browser is a random number higher than 1024 and the port of a web server is in most cases port 80.
Is the original example correct or am I?
Best Regards,
Morgan