Precautions for the first Remote Installation of LinuxIptables rules

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.