Because there is no/etc/init.d/iptales file in Ubuntu, you cannot use commands such as service to start iptables, you need to use the modprobe command.
Start iptables
Modprobe Ip_tables
Close iptables (Close command is more complex than start)
Iptalbes-f
Iptables-x
Iptables-z
Iptables-p INPUT ACCEPT
Iptables-p OUTPUT ACCEPT
Iptables-p FORWARD ACCEPT
Modprobe-r Ip_tables
Execute the above command in turn to turn off iptables, otherwise you will be prompted Fatal:module Ip_tables is when you execute Modproble-r ip_tables
Code:# Remove the existing rules from the original iptables
Iptables-f
Iptables-x
# Discard all packets that don't match three chain rules
Iptables-p INPUT DROP
Iptables-p OUTPUT DROP
Iptables-p FORWARD DROP
# Settings: Input and OUTPUT links for local process lo; eth1 input chain
Iptables-a input-i lo-j ACCEPT
Iptables-a input-i eth1-m State--state established,related-jaccept
Iptables-a input-i eth1-m State--state new,invalid-j LOG
Iptables-a Output-o lo-j ACCEPT
# Output settings for the other main allowed ports:
# DNS
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 53-jaccept
Iptables-a output-o eth1-p UDP--sport 1024:65535--dport 53-jaccept
#http
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 80-jaccept
#HTTPS
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 443-jaccept
#Email Accept and send
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 110-jaccept
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 25-jaccept
# FTP Data and control
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 20-jaccept
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 21-jaccept
#dhcp
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 68-jaccept
Iptables-a output-o eth1-p UDP--sport 1024:65535--dport 68-jaccept
#POP3S Email Secure Reception
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 995-jaccept
# Time Synchronization Server NTP
Iptables-a output-o eth1-p TCP--sport 1024:65535--dport 123-jaccept
#拒绝 eth1 the rest.
Iptables-a output-o eth1--match State--state New,invalid-jlog
Finally, there are commands about the Iptables store:
Code:Iptables-save >/etc/iptables.up.rule # There's a place you want to save
Code:Iptables-restore </etc/iptables.up.rules # Call because Iptables needs to be entered or called again after each machine reboot, in order to facilitate operation, use
Code:sudo gedit/etc/network/interfaces
In
Code:Auto Ath0
Iface Ath0 inet DHCP
After adding
Code:pre-up iptables-restore </etc/iptables.up.rules # Start automatic call to stored iptables
Code:Post-down Iptables-save >/etc/iptables.up.rule #关机时 to store the current iptables
Ubuntu iptables Settings