UbuntuServer adds iptables firewall rules

Source: Internet
Author: User
# Writebyloulancn@163.comUbuntuServer add iptables firewall rules Step 1: create rules root @ loulancn:/etc/apt # vi/etc/iptables * filter: INPUTACCEPT [0: 0]: FORWARDACCEPT [0: 0]: OUTPUTACCEPT [0: 0]: FW-[0: 0]-AINPUT-

# Write by loulancn@163.com

Added iptables firewall rules for Ubuntu Server

Step 1: create rules

Root @ loulancn:/etc/apt # vi/etc/iptables

* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
: FW-[0: 0]
-A input-j FW
-A forward-j FW
-A fw-I lo-j ACCEPT
-A fw-p icmp-type any-j ACCEPT
-A fw-m state-state ESTABLISHED, RELATED-j ACCEPT
-A fw-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT
-A fw-m state-state NEW-m tcp-p tcp-dport 22-j ACCEPT
-A fw-j REJECT-reject-with icmp-host-prohibited
COMMIT

Add the corresponding iptables rules. (The rules configured by loulancn only allow basic services. Please customize them)

Step 2: apply rules

Edit the network configuration file. In the configuration file of the corresponding Nic, add vi/etc/network/interfaces

Pre-up iptables-restore/etc/iptables

For example, local configuration

Auto eth0
Iface eth0 inet static
Address 119 .*.*.*
Netmask 255 .*.*.*
Network 119. *. *. 0
Broadcast 119 .*.*.*
Gateway 119 .*.*.*
Pre-up iptables-restore/etc/iptables

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.