Guide to open ports in CentOS 7 Back

To Open Specific port in CentOS-7

 

Introduction

In networking terminology, ports are termed as logical connection places which use TCP/IP and UDP (User Diagram Protocol) to specify a particular server program from a client program or computer in a network. Port numbers range from 0 to 65535 each of which is assigned to a particular service in the network. For example, HTTP services use port 80 as default. Similarly, port 8080 refers to a place in the network to host an alternate web server.

in Linux based operating systems, ports are opened using Iptables. In this brief guide, we will discuss the steps involved to open ports in CentOS

 

Step 1: Login requirements

In order to change the firewall settings, you must have access to non-root superuser account, with sudo privileges set up on your server. First you need to know that iptables commands must be run with root privileges only. To implement this condition, we shall add “sudo” before all the commands in this guide. We can also login as root user by using “su” or “sudo -i” commands but we will stick with “sudo” for this guide.

 

Step 2: Checking current firewall rules

Initially we need to find the current rules that are configured for the firewall. This is achieved by using the following command:

#firewall-cmd --list-ports

 

Step 3 : Open Specific port

There are various port numbers ranging from 0 to 65535 that can be added. Lets take port 80 for our reference which correspond to HTTP services. Use the following command to add port 80 into the firewall chain.

[root@centos7 ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@centos7 ~]# firewall-cmd --reload
success

 

If the --permanent flag is not specified, this will only change the running configuration but will not be saved.

We can check the ports that are opened in the current default zone with ‘--list-ports.

[root@centos7 ~]# firewall-cmd --list-ports
80/tcp

 

 

TESTIMONIALS

Copyright © 2024 Cloudops, All rights reserved. Privacy Policy