能PING通,访问不了web,先在CMD测试telnet ip 80看看是否是防火墙的问题.
修改防火墙,打开指定端口
1 安装iptables
[root@centos ~]# yum install iptables-services
设置防火墙规则 (增加80端口)
[root@centos ~]# vim /etc/sysconfig/iptables
打开文件,增加80端口那一行
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-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 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq #保存退出
2 默认firewall作为防火墙的设置
#禁止firewall开机启动
[root@centos ~]# systemctl disable firewalld.service
#设置防火墙开机启动
[root@centos ~]# systemctl enable iptables.service
#停止firewall
[root@centos ~]# systemctl stop firewalld.service
#重启防火墙使配置生效
[root@centos ~]# systemctl restart iptables.service (必须重启)
3 查看当前系统打开的端口
[root@centos ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2157/master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1292/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2157/master
tcp6 0 0 :::22 :::* LISTEN 1292/sshd