Redirecting my local address to my virtual machine

2019-03-06 17:21发布

问题:

i'm working on an academic project (nothing professional) and wonder if i can set a rule that will permit me to redirect my local ip address to my virtual machine address, the virtual machine is an HTTP server, so i need to check my website from other computers on the same network, in other computers i will write the IP of my server computer(containing a vm) and then that IP will be translated to my vm IP.

回答1:

Two options:

1) Use a bridged NIC. The VM will have an IP address in the same subnet as the host machine, assuming DHCP is active. That's the simplest.

2) If VMware Workstation, attach the VM to the NAT switch. In Network Configuration you can then port forward so when your host IP receives traffic on port X it can forward that traffic to NAT client IP port X (or Y). I can't remember if VMware Player has NAT port forwarding.



回答2:

From the host machine you could use the following Netsh command under cmd with administrator privileges:

netsh interface portproxy add v4tov4 listenport=80 connectaddress=192.168.0.10

providing that the vm IP address is 192.168.1.10 (replace with the actual one and make it static), the HTTP server is on port 80, and IPv4 is used.

After successful entry you may confirm the rule by using the following command:

netsh interface portproxy show all

For more information you may consult the following link:

http://technet.microsoft.com/en-us/library/cc731068(v=ws.10).aspx#BKMK_1