How to Open/Allow incoming firewall port on Ubuntu 20.04 examples

  1. Open incoming TCP port 53 to any source IP address:
    $ sudo ufw allow from any to any port 53 proto tcp
    
  2. Open incoming TCP port 443 to only specific source IP address eg. 10.1.1.222:
    $ sudo ufw allow from 10.1.1.222 to any port 443 proto tcp
  3. Open incoming UDP port 53 to source subnet eg. 10.1.1.0/8:
    $ sudo ufw allow from 10.1.1.0/8 to any port 53 proto udp
  4. Open incoming TCP ports 20 and 21 from any source, such as when running an FTP server:
    $ sudo ufw allow from any to any port 20,21 proto tcp
    
  5.  Open port for a specific web server such as Apache or Nginx execute the bellow Linux command:
    $ sudo ufw allow in "Apache Full"
    $ sudo ufw allow in "Nginx Full"
    
  6.  Open port for a specific service such as SSH:
    $ sudo ufw allow in ssh
Was this answer helpful? 0 Users Found This Useful (0 Votes)