Ubuntu iptables Configuration

Source: Internet
Author: User


Ubuntu iptables Configuration:


1, Ubuntu default is installed Iptables, can be confirmed by dpkg-l or which iptables


2, Ubuntu default does not have iptables configuration file, need to be generated through Iptables-save >/etc/network/iptables.up.rules


3, iptables configuration file path and file name is recommended as/etc/network/iptables.up.rules, because execution iptables-apply by default point to the file, you can also specify the file through the-w parameter


3, Ubuntu does not restart Iptables command, the implementation of iptables-apply effective


4, Ubuntu iptables default restart server after emptying, need to write in/etc/network/interfaces pre-up Iptables-restore </etc/network/ Iptables.up.rules will not be active until the boot



Several iptables commands:


Allow all access to port 22:

# iptables-a input-p TCP--dport 22-j ACCEPT


Deny all access to port 22:

# iptables-a input-p TCP--dport 22-j DROP



Allow only 10.0.0.2 access to port 22:

# iptables-a input-p TCP--dport 22-s 10.0.0.2-j ACCEPT


Note: Allow policies to be written to the top of the reject, otherwise useless



To view the Iptables policy:

# iptables-l


Save the policy to the specified file (the following file path and filename can be customized):

# Iptables-save >/etc/network/iptables.up.rules


Apply policy:


# iptables-apply

Enter Y


Delete the policy (you need to cat/etc/network/iptables.up.rules confirm the deletion of the first few lines, or directly manipulate the/etc/network/iptables.up.rules file is also OK):


# iptables-d INPUT 2




This article is from the "Linux" blog, so be sure to keep this source http://yangzhiming.blog.51cto.com/4849999/1982814

Ubuntu iptables Configuration

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.