Press enter to see results or esc to cancel.

Wanna buy Bitcoin, and start winning? Just click for join >

Open and Close Port in Linux

For more secure server, we have to close some ports to users. If need access to this ports, we can give permission to our IP address. We need static IP address for this operation. Please dont forget, “iptables” can be block all IP address but when you restart the server it will be clean all of this commands. (I am using Fedora)

Closing FTP port except

iptables -t filter -I INPUT 1 -p tcp -s ! –dport 21 -j REJECT –reject-with icmp-host-prohibited

Closing SSH port except

iptables -t filter -I INPUT 1 -p tcp -s ! –dport ssh -j REJECT –reject-with icmp-host-prohibited

Closing MySQL port except localhost

iptables -A INPUT -i eth0 -s -p tcp –destination-port 3306 -j ACCEPT

Listing iptables list

iptables -L

Removing iptables data (Removing first one in list, type 2 for second one)

iptables -D INPUT 1


Comments are disabled for this post