"Go" Ubuntu firewall settings

Source: Internet
Author: User

1. Installation
sudo apt-get install UFW

2. Enable
sudo UFW enable
sudo ufw default deny
After running the above two commands, the firewall is turned on and turned on automatically when the system starts.
All external access to the native is turned off, but the native access is normal externally.

3. Turn ON/off
sudo ufw allow|deny [service]
Open or close a port, for example:
sudo UFW allow SMTP allows all external IPs to access native 25/TCP (SMTP) ports
sudo ufw allow 22/tcp allows all external IP access to the native 22/tcp (SSH) port
sudo UFW allow 53 allows external access to 53 ports (TCP/UDP)
sudo ufw allow from 192.168.1.100 allows this IP access to all native ports
sudo ufw allow proto UDP 192.168.0.1 port 192.168.0.2 port 53
sudo UFW deny SMTP prevents external access to the SMTP service
sudo ufw delete allow SMTP to delete a rule established above

4. View firewall status
sudo UFW status

For general users, only the following settings are required:
sudo apt-get install UFW
sudo UFW enable
sudo ufw default deny
The above three commands are safe enough, if you need to open some services, then use sudo ufw allow to open.
Add:

Turn firewall on/off (the default setting is ' Disable ')

# UFW Enable|disable

Convert log status

# UFW Logging On|off

Set default policy (e.g. "mostly open" vs "mostly closed")

# UFW Default Allow|deny

License or block certain incoming packets (you can view the list of services in "status" [see below]). You can specify a service name that exists in/etc/services in the "Protocol: port" mode, or through the meta-data of the package. The ' Allow ' parameter will add the entry to/etc/ufw/maps, while ' deny ' is the opposite. The basic syntax is as follows:

# UFW Allow|deny [service]

Displays the listening state of the firewall and port, see/var/lib/ufw/maps. The numbers in parentheses will not be displayed.

# UFW Status

[Note: Although sudo is not used above, the command prompt symbol is ' # '. So...... You know what that means, huh? This is the original. --The translator's note]


UFW Use Example:

Allow Port 53

$ sudo ufw allow 53

Disable Port 53

$ sudo ufw delete Allow 53

Allow Port 80

$ sudo ufw allow 80/tcp

Disable Port 80

$ sudo ufw delete Allow 80/tcp

Allow SMTP ports

$ sudo ufw allow SMTP

Remove licensing for SMTP ports

$ sudo ufw delete allow SMTP

Allow a specific IP

$ sudo ufw allow from 192.168.254.254

Delete the above rule

$ sudo ufw delete allow from 192.168.254.254

Original: http://baisongfly.blog.163.com/blog/static/30135117200923005956159/

"Go" Ubuntu firewall settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.