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?

2 / 0

Leave a Reply 21

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.

betments

betments

I got this website from my friend who told me on the topic of this web site and at the
moment this time I am visiting this site and reading very informative articles or reviews at this time.

Carmine

Carmine

I simply could not leave your web site prior to suggesting that I extremely enjoyed the
standard info an individual supply to your guests?
Is gonna be back regularly in order to check out new posts

Rosanna Knowling

Rosanna Knowling

Very informative and useful post. You have nice command on the post and have explained in a very great way. Thanks for helping .Good work,hope your blog be better!I just want to make a blog like this!

websijoka

websijoka

What’s up to all, how is the whole thing, I think every one is getting more from
this website, and your views are fastidious in support of new users.

joker12

joker12

It’s remarkable for me to have a website, which is beneficial in support of my experience.
thanks admin

jokemsu

jokemsu

Hey would you mind letting me know which webhost you’re working with?
I’ve loaded your blog in 3 completely different
internet browsers and I must say this blog loads
a lot faster then most. Can you suggest a good hosting provider at a reasonable
price? Thanks, I appreciate it!

proview

proview

Good shot dude