Simple Firewall settings in Linux

Source: Internet
Author: User

For personal VPs, simple firewall settings are also necessary. The specific method is as follows:

1. Check whether the firewall function is Enabled:
#/Etc/init. d/iptables status

2. Set the preset policies for the input, output, and forwarding links:
# Iptables-P input accept
# Iptables-P output accept
# Iptables-P forward accept

3. Clear all default firewalls:
# Iptables-F
# Iptables-x
# Iptables-z

4. Set the loopback interface to be unrestricted:
# Iptables-A input-I lo-J accept

5. set to open all response packages for requests sent by the Local Machine
# Iptables-A input-M State-State related, established-J accept

6. Enable the WWW Service provided by the local machine:
# Iptables-A input-p tcp-dport 80-J accept

7. set to release the SSH service provided by the local machine:
# Iptables-A input-p tcp-dport 22-J accept

8. Set the preset input chain policy to drop:
# Iptables-P input drop

9. Save the route information:
#/Etc/init. d/iptables save

Note:
You need to set the Default policy of the input chain to accept and leave a path for yourself to avoid the SSH connection being blocked by the firewall. In this case, you can only try to restart the server, or you can log on to the server using TTY. Therefore, set the input policy to accept, perform firewall operations, and then run "iptables-P input drop ".

 

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.