How to add service or port by Firewall on centos 7

First install firewall on your system :

yum install firewalld -y

Now start & enable firewall :

systemctl start firewalld
systemctl enable firewalld
systemctl status firewalld

Now see how many zones in your system & who is your default zone :

firewall-cmd --get-zones
firewall-cmd --get-default-zone

Your default zone must be public if not then set default zone to public or your system may not work properly :

firewall-cmd --set-default-zone=public

Now see the permanent list of all services & ports on your public zone :

firewall-cmd --permanent --zone=public --list-all

If you need to add any service on your public zone then you can add like this :

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --list-services

If you want to remove any service from your public zone you can do like this :

firewall-cmd --permanent --zone=public --remove-service=http

Now add a port to public zone & remove it if you need by this command :

firewall-cmd --permanent --zone=public --add-port=2222/tcp
firewall-cmd --zone=public --list-ports
firewall-cmd --permanent --zone=public --remove-port=25/tcp
You must say what is the protocol it is tcp or udp during adding a port.

Thank you for reading this article.

Was this helpful?

3 / 0

Leave a Reply 18

Your email address will not be published. Required fields are marked *


bripiruffedia

bripiruffedia

Wow!!! Thanks.

Neefvoingenew

Neefvoingenew

Thanks!

morenfo

morenfo

Simply desire to say your article is as astounding. The clarity in your post is just great and i can assume you’re an expert on this subject. Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please continue the gratifying work.

Mariel

Mariel

It’s amazing to pay a visit this site and reading
the views of all friends on the topic of this article, while I am
also keen of getting familiarity.

Niamh

Niamh

Hi Dear, are you in fact visiting this website daily, if so afterward you will
without doubt get fastidious knowledge.

Melodee

Melodee

Thanks for another informative blog. The place else could I am getting that type of info written in such an ideal means?
I have a venture that I am simply now working on, and I’ve been at the glance out for such information.

butpsam

butpsam

I’m not that much of a internet reader to be honest but your sites really nice, keep it up!
I’ll go ahead and bookmark your website to come back in the future.
Cheers

pgamour

pgamour

This is really fascinating, You’re an overly professional blogger.
I have joined your feed and sit up for in the hunt for
extra of your great post. Also, I’ve shared your website in my social networks

pheir

pheir

I am in fact delighted to glance at this blog posts which contains tons of valuable information,
thanks for providing these information.

Maribel

Maribel

You need to be a part of a contest for one of the most useful blogs on the web.
I will highly recommend this site!

Franklin

Franklin

A person necessarily assist to make significantly articles I’d state.
That is the very first time I frequented your website page and to
this point? I amazed with the analysis you made to make this actual put up incredible.
Magnificent process!

Junko

Junko

Howdy! Do you know if they make any plugins to safeguard against hackers?
I’m kinda paranoid about losing everything I’ve worked hard on. Any recommendations?

Tamela

Tamela

I know this web site presents quality based posts and other data, is there any other site which offers these kinds of things in quality?

Paulina

Paulina

Hi there, i read your blog from time to time and i own a
similar one and i was just curious if you get a lot of spam comments?
If so how do you prevent it, any plugin or anything you can advise?
I get so much lately it’s driving me insane so any support is very much appreciated.

portunit

portunit

This article is a breath of fresh air! The author’s unique perspective and insightful analysis have made this a truly captivating read. I’m appreciative for the effort he has put into creating such an educational and thought-provoking piece. Thank you, author, for offering your knowledge and stimulating meaningful discussions through your brilliant writing!

hemain

hemain

Thank you, I’ve just been searching for info about this subject for ages and yours is the best I have discovered till now.

remoparent

remoparent

Hello there, I found your web site via Google while looking for a related topic, your web site came up, it looks great. I’ve bookmarked it in my google bookmarks.

prestigeautod

prestigeautod

This is one awesome article post.Thanks Again. Will read on…