Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Last active October 30, 2018 12:42
Show Gist options
  • Save rraallvv/693107f1f85a3afc8589d8a41000cf9f to your computer and use it in GitHub Desktop.
Save rraallvv/693107f1f85a3afc8589d8a41000cf9f to your computer and use it in GitHub Desktop.
How to open/close port on centOS

Open port on Cent OS 6 and earlier:

Step 1

nano /etc/sysconfig/selinux

Make sure the file has this configurations

SELINUX=disabled

SELINUXTYPE=targeted

Then restart the system

Step 2

iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT

Step 3

sudo service iptables save

Open port on Cent OS 7:

step 1

firewall-cmd --zone=public --permanent --add-port=8080/tcp

Step 2

firewall-cmd --reload

Source: https://stackoverflow.com/a/39327402/1436359

Close port

firewall-cmd --zone=public --remove-port=8080/tcp
firewall-cmd --runtime-to-permanent 
firewall-cmd --reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment