Skip to main content

Posts

Showing posts from November, 2009

Mastering Iptable Command Line Usage Linux Networking

Some of the most useful commands related to iptable , To display filter table rules. #iptables -t filter -L To display nat table rules. #iptables -t nat -L To display raw table rules #iptables -t raw -L To display mangle table rules. #iptables -t mangle -L To delete all rules in the filter,nat,raw and mangle table. #iptables -t filter -D #iptables -t nat -D #iptables -t raw -D #iptables -t mangle -D Set up IP FORWARDing and Masquerading # iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE The above rule will do source nating. ( It will set eth0 IP address as source address for all outgoing packets on interface eth0.) # iptables --append FORWARD --in-interface eth1 -j ACCEPT Port forwading # iptables -t nat -A PREROUTING -i eth0 -d --dport -j DNAT --to The above rule will change the destinationIP:portnumber of the incoming packet to private.IP:portnum Enabing the packet forward in the kernel with proc entry. #echo 1 > /proc/sys/net/ipv4/ip_forward iptables ...