Requirements

  • Root Access for the server

 

Procedure

 

Open Port in CentOS 6

  1. Log in to the root of your server
  2. Run the following commands to open port 5555

    /sbin/iptables -D INPUT -p tcp --destination-port 5555 -j DROP
    /sbin/service iptables save
    iptables -S

 

Close Port in CentOS 6

  1. Log in to the root of your server.
  2. Run the following commands to close port 5555

    /sbin/iptables -A INPUT -p tcp --destination-port 5555 -j DROP
    /sbin/service iptables save
    iptables -S

 

Open Port in CentOS 7

  1. Log in to the root of your server.
  2. Run the following commands to open 5555


    firewall-cmd --reload

 

Close Port in CentOS 7

  1. Log in to the root of your server.
  2. Run the following commands to close 5555


    firewall-cmd --zone=public --permanent --remove-port=5555/tcp
    firewall-cmd --reload

With this, we finish the guide for opening and closing ports on the CentOS server.

 

How to check if a particular port is open?

  • In terminal type the following command to check open port. For Example, we tried checking Port 22 on our server.

    netstat -lntu | grep 22

    If the port is open then this will show the details for the port along with the protocol used.
    If you see no output then that means the port is not open or running on your Linux Machine
  • If you want to check all the open ports then kindly run the following command

    netstat -lntu


Дали Ви помогна овој одговор? 0 Корисниците го најдоа ова како корисно (0 Гласови)