Run the following command to generate the/etc/sysconfig/iptables list [root @ centos ~] #/Etc/init. d/iptablesrestart after this operation is completed, the system will automatically generate a ChainRH-Firewall-1-INPUT linked list, but the system default INPUT, OUTPUT, FORWARD linked list is ACCEPT, you need
Run the following command to generate/etc/sysconfig/IptablesColumn table
[Root @Centos~] #/Etc/init. d/iptables restart
After this operation is complete, the system will automatically generate a Chain RH-Firewall-1-INPUT linked list
However, the system's default INPUT, OUTPUT, and FORWARD linked lists are all ACCEPT. you need to DROP the INPUT chain
The command is as follows:
[Root @ centos ~] # Iptables-P INPUT DROP
Then save the rule.
[Root @ centos ~] # Service iptables save
[Root @ centos ~] # Vim/etc/sysconfig/iptables
# Firewall configuration written bysystem-config-securitylevel
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
: RH-Firewall-1-INPUT-[0: 0]
-A input-j RH-Firewall-1-INPUT
-A forward-j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT-I lo-j ACCEPT
-A RH-Firewall-1-INPUT-p icmp -- icmp-type any-j ACCEPT
-An RH-Firewall-1-INPUT-p 50-j ACCEPT
-An RH-Firewall-1-INPUT-p 51-j ACCEPT
-A RH-Firewall-1-INPUT-p udp -- dport 5353-d 224.0.0.20.- jACCEPT
-A RH-Firewall-1-INPUT-p udp-m udp -- dport 631-j ACCEPT
-A RH-Firewall-1-INPUT-p tcp-m tcp -- dport 631-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state ESTABLISHED, RELATED-jACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 21-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 443-j ACCEPT
-A RH-Firewall-1-INPUT-j REJECT -- reject-withicmp-host-prohibited
COMMIT
Edit/etc/sysconfig/iptables
Add one row
-A RH-Firewall-1-INPUT-s 10.200.1.222-m state -- state NEW-mtcp-p tcp -- dport 22-j ACCEPT
This command restricts ssh access and only allows access to 10.200.1.222
Restart/etc/init. d/iptables after modification.
[Root @ centos ~] # Iptables-nL
Chain INPUT (policy ACCEPT)
Target prot optsource destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
Target prot optsource destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
Target prot optsource destination
Chain RH-Firewall-1-INPUT (2 references)
Target prot optsource destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 icmp type 255
ACCEPT esp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT ah -- 0.0.0.0/0 0.0.0.0/0
ACCEPT udp -- 0.0.0.0/0 224.0.0.20.udpdpt: 5353
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 uddpt: 631
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt: 631
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0