Open ports:
The code is as follows |
Copy Code |
[root@wx32 ~]# iptables-i input-p tcp--dport 80-j ACCEPT |
Save configuration:
The code is as follows |
Copy Code |
[root@wx32 ~]# Service Iptables Save Saving firewall rules to/etc/sysconfig/iptables: [OK] |
Reboot the firewall:
The code is as follows |
Copy Code |
[root@wx32 ~]# Service iptables restart Flushing firewall rules: [OK] Setting chains to Policy Accept:filter [OK] Unloading iptables modules: [OK] Applying iptables firewall rules: [OK] Loading additional iptables modules:ip_conntrack_netbios_n[OK] |
To view the configuration:
The code is as follows |
Copy Code |
[root@wx32 ~]# service iptables status Table:filter Chain INPUT (Policy ACCEPT) Num Target prot opt source destination 1 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:80 |
Port View Method:
The code is as follows |
Copy Code |
[Root@vcentos ~]#/etc/init.d/iptables Status Table:filter Chain INPUT (Policy ACCEPT) Num Target prot opt source destination 1 ACCEPT UDP--0.0.0.0/0 0.0.0.0/0 UDP dpt:80 2 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:80 3 Rh-firewall-1-input All--0.0.0.0/0 0.0.0.0/0 Chain FORWARD (Policy ACCEPT) Num Target prot opt source destination 1 Rh-firewall-1-input All--0.0.0.0/0 0.0.0.0/0 |
Add:
View CentOS Firewall information:/etc/init.d/iptables status
Turn off the CentOS Firewall service:/etc/init.d/iptables stop
Check that the server's 80 port is blocked by the firewall, you can use the command: Telnet server_ip 80来 test.
The code is as follows |
Copy Code |
1> The solution is as follows: /sbin/iptables-i input-p TCP--dport 80-j ACCEPT 2> then Save: /etc/rc.d/init.d/iptables Save 3> reboot the firewall /etc/init.d/iptables restart |