Iptables-F # Allow packets from port 22 to enter iptables-AINPUT-ptcp -- dport22-jACCEPT # Allow packets from port 22 to return iptables-AOUTPUT-ptcp -- sport22-mstate -- stateESTABLISHED-jACCEPTiptables-AOUTPUT- pudp -- dp
Iptables-F
# Allow package entry from port 22
Iptables-a input-p tcp -- dport 22-j ACCEPT
# Return of packets allowed to enter from port 22
Iptables-a output-p tcp -- sport 22-m state -- state ESTABLISHED-j ACCEPT
Iptables-a output-p udp -- dport 53-j ACCEPT
Iptables-a input-p udp -- sport 53-j ACCEPT
# Allow local access to the local machine
Iptables-a input-s 127.0.0.1-d 127.0.0.1-j ACCEPT
Iptables-a output-s 127.0.0.1-d 127.0.0.1-j ACCEPT
# Allow all IP addresses to access port 80
Iptables-I INPUT-p tcp -- dport 80-j ACCEPT
Iptables-a output-p tcp -- sport 80-m state -- state ESTABLISHED-j ACCEPT
# Save configuration
Iptables-save>/etc/sysconfig/iptables
Iptables-restore </etc/sysconfig/iptables
Iptables-L
Iptables-save only lists the current settings, rather than saving the configuration
If you are using the RedHat series, use service iptables save to save and use chkconfig iptableson to enable startup.
If it is not a RedHat series, you can use the following method to manually save/restore the configuration