How To: Ubuntu Linux Firewall Open Port Command

H

ow do I open port 80 and 443 on a Ubuntu Linux LTS version 14.04 server?

 

Ubuntu Linux server comes with firewall configuration tool called ufw (Uncomplicated Firewall). It is the default tool. ufw is very easy to use and configure host based firewall settings. This program is for managing a Linux firewall and aims to provide an easy to use interface for the user. For example:

You can open/close ports.

Block an IPv4/IPv6 address.

Delete existing firewall rules.

Turn on or off firewall logs.

And more.

How do I see the current status of my firewall?

Type the following command:

sudo ufw status verbose

 

Sample outputs:

Fig.01: Check the status of UFW on a Ubuntu Linux

How do I open tcp port # 22?

To allow incoming tcp packets on port 22, enter:

sudo ufw allow 22/tcp

 

Verify it:

sudo ufw status verbose

How do I open tcp port # 80 and 443?

The service specific syntax is as follows to open http and https service ports:

sudo ufw allow http

sudo ufw allow https

 

OR

sudo ufw allow 80/tcp

sudo ufw allow 443/tcp

How do I open tcp and udp port # 53?

To allow incoming tcp and udp packet on port 53, enter:

sudo ufw allow 53

 

Verify it:

sudo ufw status verbose

Advanced examples

To allow IP address 192.168.1.10 access to port 22 for all protocols

sudo ufw allow from 192.168.1.10 to any port 22

 

Open port 74.86.26.69:443 (SSL 443 nginx/apache/lighttpd server) for all, enter:

sudo ufw allow from any to 74.86.26.69 port 443 proto tcp

 

To allows subnet 192.168.1.0/24 to Sabma services, enter:

ufw allow from 192.168.1.0/24 to any app Samba

 

You can find service info as follows:

sudo ufw app list

 

Sample outputs:

Available applications:

Nginx Full

Nginx HTTP

Nginx HTTPS

Squid

To get information on Squid profile/app, run:

ufw app info Squid

 

Sample outputs:

Profile: Squid

Title: Squid proxy cache

Description: Internet object cache (WWW proxy cache)

 

Ports:

2048,3128,3130,3401,4827/tcp

See ufw command man page for more info.

This entry is 6 of 6 in the Uncomplicated Firewall (UFW) series. Keep reading the rest of the series:

How to install UFW firewall on Ubuntu 16.04 LTS server

How to open ssh port using ufw on Ubuntu/Debian Linux

How to configure ufw to forward port 80/443 to internal server hosted on LAN

How to block an IP address with ufw on Ubuntu Linux server

How to limit SSH (TCP port 22) connections with ufw on Ubuntu Linux

How To: Ubuntu Linux Firewall Open Port Command Using UFW

 

 

Leave a Reply

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