UbuntuLinux uses ufw or iptables to configure the firewall

Source: Internet
Author: User
The firewall only supports ssh (port 22) and http (port 80 ). ubuntuLinux can do this using ufw: sudoufwenable & amp; \ sudoufwdefadendeny & amp; \ sudoufwallow22/tcp & amp; \ sudoufwallow80/tcp & amp; &

The firewall only supports ssh (port 22) and http (port 80 ).

In Ubuntu Linux, ufw can be used as follows:
Sudo ufw enable &&\
Sudo ufw default deny &&\
Sudo ufw allow 22/tcp &&\
Sudo ufw allow 80/tcp &&\
Sudo ufw status
You can delete it like this, for example, port 80:
Sudo ufw delete allow 80/tcp

Ubuntu ufw firewall rules order problem see http://www.linuxidc.com/Linux/2015-11/125110.htm

Ubuntu uses iptables to do this:
Sudo ufw disable & sudo ufw default allow sets INPUT/FORWARD/OUTPUT to ACCEPT. If it is DENY, the next step will interrupt all network access to the system, including ssh.
Sudo iptables-F & sudo iptables-X & sudo iptables-Z & sudo iptables-L
Sudo iptables-a input-m state -- state ESTABLISHED, RELATED-j ACCEPT
Sudo iptables-a input-I lo-j ACCEPT
Sudo iptables-a input-p tcp-I eth0 -- dport 22-j ACCEPT
Sudo iptables-a input-p tcp-I eth0 -- dport 80-j ACCEPT
Sudo iptables-a input-j DROP
Iptables-save>/etc/iptables. up. rules switch to the root user for execution. sudo will prompt that you do not have the permission. RedHat's save operation is service iptables save.
Add a line to the end of sudo nano/etc/network/interfaces and apply the firewall rules when the network starts:
Pre-up iptables-restore </etc/iptables. up. rules
View the configured rules:
Sudo iptables-nvL -- line-numbers
Insert a rule to 6th of the INPUT chain:
Sudo iptables-I INPUT 6-j DROP
Modify the 6th rules of the INPUT chain:
Sudo iptables-r input 6-j ACCEPT
Delete 6th rules of the INPUT chain:
Sudo iptables-d input 6

For more iptables tutorials, see the following content::

CentOS 7.0 disable default firewall enable iptables firewall http://www.linuxidc.com/Linux/2015-05/117473.htm

Iptables usage example detailed http://www.linuxidc.com/Linux/2014-03/99159.htm

Linux Firewall iptables detailed tutorial http://www.linuxidc.com/Linux/2013-07/87045.htm

Basic use http://www.linuxidc.com/Linux/2013-08/88535.htm for iptables backup, recovery, and firewall scripts

Linux Firewall iptables detailed explanation of usage rules http://www.linuxidc.com/Linux/2012-08/67952.htm

Linux iptables firewall settings http://www.linuxidc.com/Linux/2015-10/123843.htm

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2016-02/128478.htm

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.