To enable port 80 access in CentOS firewall settings, we add port 80 as an example: [root @ centoshttpd] #/sbin/iptables-IINPUT-ptcp -- the dport80-jACCEPT saves [root @ centoshttpd] #/etc/rc. d/init. d/iptablessaveiptables: set
Enable port 80 access in CentOS firewall settings
The following is an example of adding port 80:
[Root @ centos httpd] #/sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT
Save
[Root @ centos httpd] #/etc/rc. d/init. d/iptables save
Iptables: save the firewall rules to/etc/sysconfig/iptables: [OK]
If the above steps are not complete, it may be that the iptables file uses include call.
Generally, this path is/etc/sysconfig/iptables.
Or use vi to open the file and modify it.
[Root @ centos httpd] # vi/etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Tue Feb 14 07:32:18 2012
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [7: 640]
-A input-p tcp-m tcp -- dport 10000-j ACCEPT
-A input-p tcp-m tcp -- dport 80-j ACCEPT
-A input-m state -- state RELATED, ESTABLISHED-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-I lo-j ACCEPT
-A input-p tcp-m state -- state NEW-m tcp -- dport 22-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
# Completed on Tue Feb 14 07:32:18 2012
Restart the service
[Root @ centos httpd] # service iptables restart
Iptables: clear firewall rules: [OK]
Iptables: Set the chain to policy ACCEPT: filter [OK]
Iptables: uninstalling module: [OK]
Iptables: application firewall rules: [OK]
Check whether the port is effective:
[Root @ centos httpd] #/etc/init. d/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: 10000
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt: 80
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,
4 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
6 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp
7 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with ic
Chain FORWARD (policy ACCEPT)
Num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with ic
Chain OUTPUT (policy ACCEPT)
Num target prot opt source destination
Original from [wind letter network], reprinted please retain the original link: http://www.ithov.com/linux/112523.shtml