具有VirtualBox IP的Firewalld转发端口始终为10.0.2.2,将丢弃源IP

我正在尝试使用虚拟框在其中安装Web服务器。

这是我的设置:

# this does nothing firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=8080 --permanent # with masquerade on/off, zone=external, no change firewall-cmd --zone=public --add-masquerade --permanent firewall-cmd --reload 

我在/etc/sysctl.confnet.ipv4.ip_forward = 1

  • 主机(Centos 7)端口:80
  • VirtualBox(Ubuntu 16.04)端口:8080

它工作,但虚拟机看到来自10.0.2.2所有通信 。 如何使主机防火墙不丢弃源IP?

我确信没有改变virtualboxconfiguration是可能的。 我使用自动化脚本重build系统,它曾经工作过。

我错过了什么? 我不想在vm上使用桥接

编辑: 我也尝试切换区'外部',并实现MASQUERADE是不是在iptables中find

我记得,只有在configurationnetworking为NAT才能在VirtualBox虚拟机上configurationIP地址10.0.xx 这就是为什么你看到来自10.0.2.2所有请求。 要解决它,你应该改变networking桥接。

这个问题很容易在Google中find。 在我的谷歌是第一个链接 。