Ubuntu default firewall install, enable, configure, port, view status related information

Source: Internet
Author: User

Ubuntu11.04 default is UFW (UFW is the abbreviation of uncomplicated firewall, not complex firewalls, cumbersome parts of the setup or need to go to the iptables) firewall, has supported the interface operation. Run the UFW command at the command line to see a list of possible actions for the prompt. The simplest operation: sudo UFW status (if you are root, remove SUDO,UFW status) to check the status of the firewall, my return is: inactive (default is inactive). sudo UFW version firewall versions: UFW 0.29-4UBUNTU1 Copyright 2008-2009 Canonical Ltd. Ubuntu system is installed by default UFW. 1. Installationsudo apt-get install UFW2. Enablesudo ufw enable sudo ufw default denyAfter 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/offsudo ufw allow|deny [service]Open or close a port, for example:sudo ufw allow SMTPAllow all external IPs to access the native 25/TCP (SMTP) portsudo ufw allow 22/tcpIt is important to allow all external IP access to the 22/TCP (SSH) port of this computer, SSH telnet is used for SECURECRT and other software suggestions to open. Or do not open the firewall.sudo ufw allowAllow external access to port 53 (TCP/UDP)sudo ufw allow from 192.168.1.100Allow this IP to access all native portssudo ufw allow proto UDP 192.168.0.1 port 192.168.0.2 Portsudo ufw deny SMTPProhibit external access to the SMTP servicesudo ufw delete allow SMTPDelete a rule created above 4. View firewall statussudo ufw statusFor general users, only the following settings are required:sudo apt-get install UFWsudo ufw enablesudo ufw default denyThe above three commands are safe enough, if you need to open some services, then use sudo ufw allow to open. Turn firewall on/off (the default setting is ' Disable ')sudo ufw enable|disableConvert log statussudo ufw logging On|offSet default policy (e.g. "mostly open" vs "mostly closed")sudo ufw default Allow|denyLicensed or shielded port (you can view the list of services in "status"). 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:sudo 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.sudo ufw statusUFW Usage Example: Allow 53 ports$ sudo ufw allowDisable Port 53$ sudo ufw delete allowAllow Port 80$ sudo ufw allow 80/tcpDisable Port 80$ sudo ufw delete allow 80/tcpAllow SMTP ports$ sudo ufw allow SMTPRemove licensing for SMTP ports$ sudo ufw delete allow SMTPAllow a specific IP$ sudo ufw allow from 192.168.254.254Delete the above rule$ sudo ufw delete allow from 192.168.254.254The Linux 2.4 Kernel later provides a very good firewall tool: Netfilter/iptables, he is free and powerful, can control the incoming and outgoing information, it can achieve firewall, NAT (network address translation) and data packet segmentation and other functions. NetFilter work inside the kernel, while iptables is the table structure that lets the user define the rule set. But Iptables's rules are slightly "complex", so Ubuntu provides UFW as a setting tool to simplify some of Iptables's settings, with the background still iptables. UFW is the abbreviation of uncomplicated firewall, some complex settings or to go to iptables. UFW related files and folders are:/etc/ufw/: There are some UFW environment settings files, such as Before.rules, After.rules, sysctl.conf, ufw.conf, and for IP6 Before6.rule and After6.rules. These files generally follow the default settings for OK. If the UFW is turned on,/etc/ufw/sysctl.conf will overwrite the default/etc/sysctl.conf file, if your original/etc/sysctl.conf has been modified, if you start UFW,/etc/ufw/ Sysctl.conf in the new assignment, it will overwrite/etc/sysctl.conf, otherwise the/etc/sysctl.conf shall prevail. Of course you can set which sysctrl.conf to use by modifying the "ipt_sysctl=" entry in/ETC/DEFAULT/UFW. /var/lib/ufw/user.rules This file is a set of some of our firewall rules, open probably can see, sometimes we can directly modify the file, do not use the command to set. After the change, remember UFW reload restart UFW make the new rule take effect. Here are some examples of the UFW command line:UFW enable/disable: Open/Close UFWUFW Status: View UFW rules that have already been definedUFW default Allow/deny: Foreign access default allow/DenyUFW Allow/deny: Allow/Deny access to port 20, 20 can be followed by/tcp or/UDP, indicating TCP or UDP packets.UFW Allow/deny ServiceName: UFW from the/etc/services to find the corresponding service port, to filter.UFW allow proto TCP from 10.0.1.0/10 to native IP port: Allow self-10.0.1.0/10 TCP packets to access port 25 on this machine.UFW Delete Allow/deny: Delete the previously defined rules for allow/Deny access to port 20

Ubuntu default firewall install, enable, configure, port, view status related information

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.