外部网访问httpd要关掉iptables吗?

WBOY
Release: 2016-06-06 20:22:00
Original
1305 people have browsed it

实验环境:win8主机,虚拟机CentOS 6.7,桥接方式连接

  1. 主机网络配置:ipaddr: 192.168.1.100
    虚拟机网络配置:

    <code>   bootproto: static
       ipaddr: 192.168.1.101
       netmask: 255.255.255.0</code>
    Copy after login
    Copy after login
  2. 虚拟机iptables配置

    <code>开放80端口: iptables -A INPUT -p tcp --dport 80 -j ACCEPT</code>
    Copy after login
    Copy after login
  3. 虚拟机lamp配置

    <code>httpd: 根目录<directory>可访问</directory></code>
    Copy after login
    Copy after login

实验步骤及结果

  1. root@cent# service iptables start

    <code>   防火墙服务正常,CentOS内部可通过访问127.0.0.1访问httpd服务, 但不能在win8外部网通过192.168.1.101:80访问该虚拟机上的httpd服务。</code>
    Copy after login
    Copy after login
  2. root@cent# service iptables stop

    <code>   防火墙关闭,CentOS和win8中均可访问httpd服务</code>
    Copy after login
    Copy after login

请问虚拟机该如何配置iptables规则?

回复内容:

实验环境:win8主机,虚拟机CentOS 6.7,桥接方式连接

  1. 主机网络配置:ipaddr: 192.168.1.100
    虚拟机网络配置:

    <code>   bootproto: static
       ipaddr: 192.168.1.101
       netmask: 255.255.255.0</code>
    Copy after login
    Copy after login
  2. 虚拟机iptables配置

    <code>开放80端口: iptables -A INPUT -p tcp --dport 80 -j ACCEPT</code>
    Copy after login
    Copy after login
  3. 虚拟机lamp配置

    <code>httpd: 根目录<directory>可访问</directory></code>
    Copy after login
    Copy after login

实验步骤及结果

  1. root@cent# service iptables start

    <code>   防火墙服务正常,CentOS内部可通过访问127.0.0.1访问httpd服务, 但不能在win8外部网通过192.168.1.101:80访问该虚拟机上的httpd服务。</code>
    Copy after login
    Copy after login
  2. root@cent# service iptables stop

    <code>   防火墙关闭,CentOS和win8中均可访问httpd服务</code>
    Copy after login
    Copy after login

请问虚拟机该如何配置iptables规则?

允许80端口开放

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!