Allow incoming/outgoing ports on iptables

2012-11-27 217 words 2 mins read

Schematic for the packet flow paths through Li...
Schematic for the packet flow paths through Linux networking and Xtables (Photo credit: Wikipedia)

Last couple of years, I just used to disable iptables on my system, this time I decided not to disable it and keep it enabled.

So far so good, now comes the tricky part, I have http server enabled on my system and since this is on local network with already firewall and other security in place so I can allow all incoming to my system and similarly I need to enable XDMCP outgoing. So, I can add the rules like this :

iptables -A INPUT -p tcp –dport 22 -j ACCEPT
iptables -A OUTPUT -p udp -s 0/0 -d 0/0 --dport 177 -j ACCEPT for XDMCP

This works only till I reboot my system and is not persistent. Okay, so I can put this in rc.local file. But why I should do that, there should be more elegnant way. So, I searched and finally found that I can simply put the rules in /etc/sysconfig/iptables as follows:

-A INPUT -p tcp –dport 22 -j ACCEPT
-A OUTPUT -p udp -s 0/0 -d 0/0 --dport 177 -j ACCEPT for XDMCP
Enhanced by Zemanta

author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it