# 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