Pages

Friday, November 12, 2010

Open Specific Port with iptables

Here's the example steps:


open port 8000:
iptables -I INPUT -p tcp --dport 8000 -j ACCEPT 


save new configuration. if don't, the port will return closed where iptables restarted:
service iptables save 


A sample iptables rule to open Linux iptables firewall
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT


OR only allow remote connection from your web server located at 10.5.1.3:
/sbin/iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT


OR only allow remote connection from your lan subnet 192.168.1.0/24:
/sbin/iptables -A INPUT -i eth0 -s 192.168.1.0/24 -p tcp --destination-port 3306 -j ACCEPT


test it: 
$ telnet 65.55.55.2 3306


note:
if the above steps doesn't work try this..

/sbin/iptables -I INPUT -p tcp -s 202.1.9.17 --dport 5434 -j ACCEPT
[user@server ~]$ sudo /etc/init.d/iptables save
Saving firewall rules to /etc/sysconfig/iptables:          [  OK  ]




ref: 

No comments:

Post a Comment