不能远程访问networking服务器

我最近安装了centos服务器。 我已经configuration了Apache和所有的mysql包。

我也有一个活的IP。 当我运行在networking服务器上的现有IP的networking服务器本身都看起来不错。 但是,当我尝试通过另一个IP远程访问,它说“无法连接”。

我也build立了iptables。 但我无法访问服务器 – 请,任何人可以帮助吗? 这是我的iptable文件:

# Generated by iptables-save v1.4.7 on Sat Mar 16 21:12:18 2013 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [20928:2320365] -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 INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT # Completed on Sat Mar 16 21:12:18 201 

这里是netstat的输出:

 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2109/mysqld tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1575/rpcbind tcp 0 0 0.0.0.0:54354 0.0.0.0:* LISTEN 1770/rpc.statd tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1971/vsftpd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1828/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2205/master tcp 0 0 :::51272 :::* LISTEN 1770/rpc.statd tcp 0 0 :::111 :::* LISTEN 1575/rpcbind tcp 0 0 :::80 :::* LISTEN 3026/httpd tcp 0 0 ::1:631 :::* LISTEN 1828/cupsd udp 0 0 0.0.0.0:43728 0.0.0.0:* 1770/rpc.statd udp 0 0 0.0.0.0:5353 0.0.0.0:* 1751/avahi-daemon udp 0 0 0.0.0.0:111 0.0.0.0:* 1575/rpcbind udp 0 0 0.0.0.0:631 0.0.0.0:* 1828/cupsd udp 0 0 0.0.0.0:902 0.0.0.0:* 1575/rpcbind udp 0 0 0.0.0.0:674 0.0.0.0:* 1770/rpc.statd udp 0 0 0.0.0.0:39847 0.0.0.0:* 1751/avahi-daemon udp 0 0 :::33127 :::* 1770/rpc.statd udp 0 0 :::111 :::* 1575/rpcbind udp 0 0 :::902 :::* 1575/rpcbind 

我也有端口80听。

你的iptables规则是错误的顺序,这个规则

 -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 

应该在这之前

 -A INPUT -j REJECT --reject-with icmp-host-prohibited 

你可能做的是使用iptables命令的-A选项。 这将规则添加到链的末尾。 iptables中的规则从上到下执行,第一条规则匹配获胜。 在你的设置中,覆盖拒绝将在允许端口80之前被执行。

解决这个问题最简单的方法就是保存当前的configuration

 service iptables save 

然后编辑/ etc / sysconfig / iptables文件并交换规则的位置,然后重新启动iptables

 service iptables restart.