Article Title: Iptables firewall configuration. 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.
# Iptables -- help
Iptables v1.3.5
Configure iptables static Firewall
Initialize Firewall
Iptables-F // -- flush-F [chain] Delete all rules in chain or all chains
Iptables-X // -- delete-chain-X [chain] Delete a user-defined chain
Iptables-Z // -- zero-Z [chain] Zero counters in chain or 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 ping 127.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 DROP LOGS]: '-- 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