I know how to open port using iptables but how i can close tcp and udp port say port number 3306 so one can enter or hack into it from internet.
Thank you.
I know how to open port using iptables but how i can close tcp and udp port say port number 3306 so one can enter or hack into it from internet.
Thank you.
English not my first language. If not understood my question ask me.
Hi,
If your default action is DROP or REJECT in iptables then you need to open required port. and if you default action is ACCEPT then you need to close particular port.
exa.
reject ssh connection from specific IP
iptables -t filter -A INPUT -s 192.168.0.1 -p tcp --dport 22 -j REJECT
HTH
wuwen1023 (9th July 2010)
/sbin/iptables -A INPUT -s IP -p tcp --dport 3306 -j ACCEPT
The IP is you trust host
After closing port, make sure you save rules:
So if you close port 22 for eth1 public interface and only allowed eth0 vpn, it will look as follows:Code:service iptables save
Just in case if you need more info try our CentOS / RHEL firewall tutorial:Code:# allow eth0 for vpn / lan session connected via eth0 /sbin/iptables -A INPUT -i eth0 -s 0/0 -p tcp --dport 22 -j ACCEPT # close port 22 for everyone at eth1 /sbin/iptables -A INPUT -i eth1 -s 0/0 -p tcp --dport 22 -j DROP # save the firewall rules /sbin/service iptables save
Last edited by nixcraft; 9th July 2010 at 10:02 PM.
All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]
There are currently 1 users browsing this thread. (0 members and 1 guests)