如何访问虚拟机中的Web服务
2017-04-05 11:36
453 查看
需求:
1、在虚拟机Vmware中安装了CentOS6.5,虚拟机使用NAT的方式;2、在CentOS中安装了APACHE 并且使用 http://192.168.237.128可以正常访问;
3、想在其他windows机器上访问该虚拟机的web服务。
解决办法:
1. 开放Linux防火墙,允许80端口的访问
1)检查防火墙[root@hadoop1 sbin]# iptables --list Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
2)在 /etc/sysconfig/iptables 添加
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
这样就允许了80端口的访问
[root@hadoop1 sysconfig]# cat iptables # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
3)重启iptables服务
[root@hadoop1 sysconfig]# service iptables restart iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: [ OK ] [root@hadoop1 sysconfig]# iptables --list Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination [root@hadoop1 sysconfig]#
2. VMware的NAT设置
选择VMware的Edit -> Virtual Network Editor -> NAT(选择VMnet8)->Edit->Port Forwarding中添加映射host port:80,virtual machine IP address:192.168.237.128,Port:80
3. 设置windows防火墙
window下进入控制面板->windows防火墙->高级->设置VMware Network Adapter VMnet8->Web 服务器(HTTP)->将虚拟机的ip加入:192.168.237.128相关文章推荐
- NAT连接的虚拟机提供web服务,如何让HOST同一局域网机器访问
- 主机访问虚拟机中linux上的web服务
- 设置外部访问ubuntu虚拟机web服务的两种方法
- “允许Web服务访问”如何使用?
- 局域网访问虚拟机里面的Web的服务
- kloxo增加了域名,怎么不能访问?如何重启web服务?
- 解决主机与虚拟机互PING,但主机无法访问虚拟机上启动的web服务
- 本地主机访问虚拟机中ubuntu的web服务
- 本机访问 VMware 虚拟机里的web服务(环境LAMP)
- CentOs虚拟机可以互相ping通,但无法访问虚拟机Web服务
- 启动docker web服务时 虚拟机端口转发 外部无法访问
- 如何让在虚拟机上搭建的web站点,被与你物理机在同一网段的计算机访问
- 如何从外网访问VMware虚拟机的Web服务
- 访问虚拟机中web服务的方法
- 宿主如何访问虚拟机中的web服务器
- 如何实现宿主机通过web访问虚拟机网站
- 访问虚拟机操作系统的web服务
- 局域网中访问虚拟机中的WEB服务
- 如何访问虚拟机(另一台设备)上运行的 Web 项目
- 如何获取访问web服务的客户端IP?客户端调用web服务时,对于有参函数能输入参数?