Iptables firewall configuration method

Source: Internet
Author: User
# Iptables -- helpiptablesv1.3.5 configure iptables static firewall initialization firewall iptables-F // -- flush-F [chain] Deleteallrulesinchainorallchainsiptables-X // -- delete-chain-X [chain] Deleteauser-def # Iptables-- Help
Iptables v1.3.5
Configure iptables static firewall
Initialize firewall
Iptables-F // -- flush-F [chain] Delete all rulesin chain or all chains
Iptables-X // -- delete-chain-X [chain] Delete a user-definedchain
Iptables-Z // -- zero-Z [chain] Zero counters in chainor all chains
Before using iptables to configure your own firewall, you must first clear any previously configured rules.
Configuration rules:
Configure the default policy
Iptables-P INPUT DROP
This command will prevent any data packets from entering the computer from being dropped ). At this time, if you ping127.0.0.1, you will find that the screen is always there, because ping cannot receive any response packets.
Create a custom chain
Iptables-N MYINPUT
# Iptables-N MYDROPLOG
Add rules
Iptables-a input-j MYINPUT
This rule forwards any packets entering the computer to a custom chain for filtering.
Iptables-a myinput-p icmp-j ACCEPT
Then enter the command ping 127.0.0.1. Will the result be the same as that of the previous command?
If you want to access the www Service
Iptables-a myinput-p tcp -- sport 80-j ACCEPT
Iptables-a myinput-p udp -- sport 53-j ACCEPT
# Iptables-a myinput-j MYDROPLOG
# Iptables-a mydroplog-j DROP
Record logs
# Iptables-I MYDROPLOG 1-j LOG -- log-prefix' [IPTABLES DROPLOGS]: '-- log-level debug
In this way, all discarded network data packets are recorded, and detailed network access information can be used to view logs. So far, a secure personal static firewall has been built and can be configured again to meet various requirements.
View firewall
Iptables-L -- line-number
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.