Port forwarding from Windows host to Windows Guest, or PC > PC (No software)

Results 1 to 1 of 1
  1. #1
    This is bullshit. alextepes is offline
    MemberRank
    Sep 2006 Join Date
    CanadaLocation
    310Posts

    Port forwarding from Windows host to Windows Guest, or PC > PC (No software)

    With RZ's DB problems right now, I had to write this for a second time.. Alright here goes.

    I didn't see anything on the forums, and guides or anything of this nature, so I figured I'd put this up for both future reference, and for others. The idea of this is to allow connections to go through a host machine to a guest machine or from a host server to a lan server. I will be giving two examples so that it's easy to understand. In this guide, my host PC is Windows 7, the Guest machine(vmware) is XP.

    Ports
    1. 15779
    2. 15881
    3. 15884

    First things first, you need to see if you're behind a router or if you have a static/dynamic IP allocated to the host PC. Which in Windows 7 you just go to Control Panel\Network and Internet\Network Connections. Here you get a list of adapters. On XP just go to Control Panel > Network Connections.

    Now, right-click the adapter and hit Status. Followed by clicking "Details" you'll see an IPv4 address. If it's 192.168, or 10.25.1.1, or whatever, usually that means LAN. But there is a way to check. Go to whatismyip.com. This will tell you your WAN IP, and if it's allocated to that NIC(Network interface controller) or not. If that IP and whatismyip.com's IP detection don't match, you're behind a router. If you're behind a router, make sure you're routing to the host PC properly with those 3 ports. Make note of the IP address when port forwarding or DMZ'ing your router. Also, make sure you know the IPv4 address of your Guest/Lan machine. You can check this the same way, but on your Guest/Lan.

    Let's get onto the fun part. The commands! Yes, not software, commands. Windows has built in capability on Win7, and most likely older versions of windows to do port forwarding and routing from good old command line. Here is how it's done. Make sure you have an elevated commandline(CMD) window open. You can open that by going to Start, and in search type "cmd", right-clicking the CMD program that comes up, and hitting "Run as Administrator". In XP, you just hit run, type cmd and hit enter.

    Routing

    Example 1:In this example, let's say your IPv4 address came up as 1.1.1.1 in Details. Also, let's say the IP of the local PC on your network or your Guest OS is 2.2.2.2.

    Route from WAN to Lan/Guest:
    Code:
    route add 1.1.1.1 mask 255.255.255.255 2.2.2.2
    Route from LAN to WAN/Host:
    Code:
    route add 2.2.2.2 mask 255.255.255.255 1.1.1.1
    Example 2:
    This example will show how you would do it behind a LAN/Router.
    LAN(Host Ipv4): 192.168.0.100
    LAN2/Guest(Guest Ipv4): 192.168.56.102
    (Also note: Sometimes when setting up a two way connection on Guest OSes, you need to add a secondary virtual adapter to the machine's settings. My first adapter is "Host only", the second one is "NAT". You may need to set your Guest machine up the same way if you haven't already.)

    Route from Lan Host to Lan/Guest:
    Code:
    route add 192.168.0.100 mask 255.255.255.255 192.168.56.102
    Route fron LAN/Guest to Lan Host:
    Code:
    route add 192.168.56.102 mask 255.255.255.255 192.168.0.100
    Port Forwarding
    listenaddress is the source IP (Host), and connectaddress is where it's going (Lan/Guest)

    Example 1:
    1. 15779
    Code:
    netsh interface portproxy add v4tov4 listenport=15779 listenaddress=1.1.1.1 connectport=15779 connectaddress=2.2.2.2
    2. 15881
    Code:
    netsh interface portproxy add v4tov4 listenport=15881 listenaddress=1.1.1.1 connectport=15881 connectaddress=2.2.2.2
    3. 15884
    Code:
    netsh interface portproxy add v4tov4 listenport=15884 listenaddress=1.1.1.1 connectport=15884 connectaddress=2.2.2.2
    Example 2:
    1. 15779
    Code:
    netsh interface portproxy add v4tov4 listenport=15779 listenaddress=192.168.0.100 connectport=15779 connectaddress=192.168.56.102
    2. 15881
    Code:
    netsh interface portproxy add v4tov4 listenport=15881 listenaddress=192.168.0.100 connectport=15881 connectaddress=192.168.56.102
    3. 15884
    Code:
    netsh interface portproxy add v4tov4 listenport=15884 listenaddress=192.168.0.100 connectport=15884 connectaddress=192.168.56.102
    The fun thing about this is you can make a .bat of these commands, put them in your startup folder and run it on boot if you want. Enjoy <3
    Last edited by alextepes; 24-11-13 at 03:45 AM.




Advertisement