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