Settings for simple firewalls under Linux

Source: Internet
Author: User

For personal VPS, simple firewall settings are also necessary, the specific method is as follows:


1. Check that the firewall function is turned on:
#/etc/init.d/iptables Status


2. Set the default policy for input, output, and forward three chains:
# iptables-p INPUT ACCEPT
# iptables-p OUTPUT ACCEPT
# iptables-p FORWARD ACCEPT


3. Clear all pre-defined firewalls:
# iptables-f
# Iptables-x
# iptables-z


4. Set the loopback interface to be unrestricted and then limited:
# iptables-a Input-i lo-j ACCEPT


5. Set up a response packet to open all requests sent by the local machine
# iptables-a input-m state–state related,established-j ACCEPT


6. Set to release the WWW service provided by this machine:
# iptables-a input-p tcp–dport 80-j ACCEPT


7. Set up the SSH service provided by this machine:
# iptables-a input-p tcp–dport 22-j ACCEPT


8. Set the default policy for the input chain to drop:
# iptables-p INPUT DROP


9. Save these routing information:
#/etc/init.d/iptables Save


Note: You need to set the input chain of the default policy for the accept, give yourself a way, lest SSH connection by firewall block, then, can only try to restart the server, or run to the server TTY login. Therefore, the input policy is first set to accept, then the operation of the firewall, and finally execute "iptables-p INPUT DROP".

More wonderful Linux video tutorials at 51CTO Academy: http://edu.51cto.com/course/courseList/id-48.html

Settings for simple firewalls under Linux

Related Article

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.