update / edit firewall & iptables on ubuntu, mint, centos

There are several ways to edit, add or change the linux firewall by using iptables:

1) edit /etc/sysconfig/iptables
manually add, change or delete lines and resave the file.

2) add rules through the terminal as follows:

eg. The following command will allow / open port 80 (ie. a web server)
sudo iptables -A INPUT -p tcp –dport 80 -j ACCEPT

eg. These two commands will alllow port 80 access only from the specified IP address (111.111.111.111) and deny port 80 for all other requests. Useful for securing SFTP, SSH or Web Access on various ports.
iptables -A INPUT -p tcp –dport 8000 -s 1.2.3.4 -s 111.111.111.111-j ACCEPT
iptables -A INPUT -p tcp –dport 8000  -j DROP

Print Friendly, PDF & Email

More Like This


Categories


CentOS Linux Ubuntu / Mint
  • Post a comment