Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to test my software runs across the internet, i.e. two machines can talk to each other via host addresses and name resolution with routers and port-forwarding in between. What's the best way to do this? I can use any OS and set up on VMs.

Machine A | Router | Modem/Internet/WAN? | DNS Server | Modem/Internet/WAN? | Router | Machine B

Basically I need to simulate a machine having an internal IP address hidden to the other machine and the machine only accessible via another IP address (the router) with port forwarding.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

You can use WANem, a linux distro especially made to emulate internet.

share|improve this answer

I've also managed to do this using two installations of VirtualBox, here's my notes:

  • Have two machines, each will simulate a LAN
  • Your router and physical LAN (192.168.1.x network) will simulate the WAN
  • Setup VirtualBox on each machine, run guest on each
  • Configure NAT on both Guests to not use default but specific LAN addressing:
    • VBoxManage modifyvm "MachineA" --natnet1 "172.23.24/24*
      • This makes the NAT Guest network 172.23.24.x
      • Internal IP of host is 172.23.24.2
      • Guest is 172.23.24.15
      • External IP (WAN IP) is 192.168.1.x
  • Configure NAT to alias as proxy, so WAN IP is passed through
    • VBoxManage modifyvm "MachineA" --nataliasmode1 proxyonly
  • Set up hostnames on the router that map to the WAN address of each virtual box host, use these names as the connect addresses

*Quote from the User Manual:

9.10 Fine-tuning the VirtualBox NAT engine 9.10.1 Configuring the address of a NAT network interface In NAT mode, the guest network interface is assigned to the IPv4 range 10.0.x.0/24 by default where x corresponds to the instance of the NAT interface +2. So x is 2 when there is only one 145 9 Advanced topics NAT instance active. In that case the guest is assigned to the address 10.0.2.15, the gateway is set to 10.0.2.2 and the name server can be found at 10.0.2.3. If, for any reason, the NAT network needs to be changed, this can be achieved with the following command: VBoxManage modifyvm "VM name" --natnet1 "192.168/16" This command would reserve the network addresses from 192.168.0.0 to 192.168.254.254 for the first NAT network instance of “VM name”. The guest IP would be assigned to 192.168.0.15 and the default gateway could be found at 192.168.0.2.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.