& Nbsp; when you perform iptables rules for the first time from remote putty to a linux host, follow these steps to avoid the trouble of remote disconnection and remote linux host login. 1. clear the original filter rules. [root @ linux ~] # Iptables-F clear the rules of all rule chains in the filter of the preset table [root @ linux
Perform the following steps for the first iptables rule from remote putty to a linux host to avoid remote disconnection and failure to log on to the remote linux host.
1. clear the original filter rules.
[Root @ linux ~] # Iptables-F clear the rules of all rule chains in the filter of the preset table
[Root @ linux ~] # Iptables-X clear the rules in the user-defined chain in the filter of the preset table
2. the information after clearing the original filter rule should look like the following:
[Root @ linux ~] # Iptables-L-n
Chain INPUT (policy ACCEPT)
Target prot opt source destination
Chain FORWARD (policy ACCEPT)
Target prot opt source destination
Chain OUTPUT (policy ACCEPT)
Target prot opt source destination
3. save the changes and restart iptables.
[Root @ linux ~] #/Etc/rc. d/init. d/iptables save
[Root @ linux ~] # Service iptables restart
4. add a remote ssh Port
[Root @ linux ~] # Iptables-a input-p tcp -- dport 22-j ACCEPT
[Root @ linux ~] # Iptables-a output-p tcp -- dport 22-j ACCEPT
5. set preset rules
[Root @ linux ~] # Iptables-p INPUT DROP
[Root @ linux ~] # Iptables-p OUTPUT ACCEPT
[Root @ linux ~] # Iptables-p FORWARD DROP
6. save the changes and restart iptables again.
[Root @ linux ~] #/Etc/rc. d/init. d/iptables save
[Root @ linux ~] # Service iptables restart
You can add rules as needed.