Article Title: Considerations for remote Implementation of LinuxIptables rules for the first time. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
To enable the iptables rule for the first time from remote putty to a linux host, follow these steps 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.