We have three chains here input, output & forward.
Input chain checks those packets which are originate outside & meant for machine
Output chain checks those packets which originate from the machine & meant for outer systems
Forward chain checks those packets which are being routed from our machine.
The best way of implementing the iptables is to create a shell script & execute it.
Some basic examples of using filtering table are as follows:-
Rule 1:
#iptables -A INPUT -s 192.168.1.0/24 -j REJECT
Rule 2:
#iptables -A INPUT -s 192.168.0.20 -p icmp -j DROP
Rule 3:
#iptables -A INPUT -m mac --mac-source 12:23:56:89:34:qw -j ACCEPT
Rule 4:
#iptables -A OUTPUT -d www.yahoo.com -j REJECT
Rule 5:
#iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Rule 6:
#iptables -A INPUT -s x.x.x.x -p tcp --dport telnet -j DROP
Deleting & Replacing rules
Rule 7:
#iptables -D INPUT 4
Rule 8:
#iptables -D INPUT -p tcp --dport telnet -j DROP
Rule 9:
#iptables -R INPUT 4 -p tcp --dport telnet -j ACCEPT
Suppose, for example, that you have a router that connects the 192.168.1.0/24 network and the
10.100.100.0/24 network. Suppose further that this firewall’s eth0 interface con-
tains the internet-addressable IP address of 66.1.5.1/8.The following Ipchains
command issued on the router would enable both private-IP networks to com-
municate via the Internet:
Rule 10:
#iptables –A FORWARD –I eth0 –s 192.168.1.0/24 –j MASQUERADE #iptables –A FORWARD –I eth0 –s 10.100.100.0/24 –j MASQUERADE
would be able to use your masquerading firewall to access your host.The fol-
lowing additions to the FORWARD chain of the filter table ensures that your
masquerading router masquerades only for your internal network
Rule 11:
#iptables –A FORWARD –s 192.168.1.0/24 –j ACCEPT #iptables –A FORWARD –d 192.168.1.0/24 –j ACCEPT #iptables –A FORWARD –s 10.100.100.0/24 –j ACCEPT #iptables –A FORWARD –d 10.100.100.0/24 –j ACCEPT #iptables –A FORWARD –j DROP
No comments:
Post a Comment