Linux Server Add Port to Firewall: ‘no route to host’ [Solved]
After running up a new server, we need to add port to Firewall if we enable Firewall. We can easily add a port to Firewall.
Table of Contents
Add Port to Firewall
Let’s check Firewall is running or not:
sudo firewall-cmd --state
If running, we have to run this command to add any port to Firewall.
sudo firewall-cmd --add-port=8080/tcp --permanent
If you want to add port to any zone, then first check the available zone:
sudo firewall-cmd --get-active-zones
You will see the zone list. It will say either public, dmz, or something else. To add a port to the public zone, run this:
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
Then remember to reload the firewall for changes to take effect.
sudo firewall-cmd --reload
Solution: ‘no route to host’
Sometimes we install and start Apache/Nginx web server and try to visit the server using IP or hostname. At this time, the server doesn’t respond.
If we run the ping command, it may show like this:
“no route to host” with static IP. Not able to ping.
We can easily solve this error. This error means we didn’t open 80 (HTTP) port. For SSL, we need to run 443 (HTTPS) port.
Let’s open the HTTP & HTTPS port by typing these commands:
#HTTP
sudo firewall-cmd --add-service=http # Running config
sudo firewall-cmd --add-service=http --permanent # Startup config
#HTTPS
sudo firewall-cmd --add-service=https # Running config
sudo firewall-cmd --add-service=https --permanent # Startup config
Don’t forget to reload the firewall for changes to take effect.
sudo firewall-cmd --reload
Notes
You may restart your webserver too:
#Apache
sudo systemctl restart httpd
#Nginx
sudo systemctl restart nginx
Here’s some Firewall commands:
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo systemctl status firewalld
sudo systemctl stop firewalld
sudo systemctl disable firewalld
The tutorial is over. Thanks for reading. ?
Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)