News

IP Address Configuration with Hyper-V: Pro Tip

I recently resurrected my old Slackware based email server project and decided that instead of handling all of my email the server would act as a spam proxy and forward all the good email to my commercial server.  My hosting situation only allows me one physical machine and for this to work I needed to run Slackware virtually and route the messages internally.

As some of you may be aware when dealing with a co-located server you are given a block of IP addresses that are then bound to the NIC so you can assign them to IIS, Email, FTP etc..  For this project I wanted to bind my new VM to an unused IP address and then route email between the machines using DNS. 

Sounds simple enough, I prepared my new Slackware VM offline and then uploaded it to the server.  From there I created the virtual machine and attached the new VHD (virtual hard drive) and all appeared to be good.  The problem was I could ping and access external websites however, I was unable to ping the host machine.  The host machine could ping the guest however it couldn’t access any resources on the guest.  I tried pulling up a web application on the guest machine and got the "server cannot be contacted" message.  I then tried accessing a SAMBA share and was prompted for a login and password.

It was almost like the machine was there but it wasn’t on the same network.

I checked ifconfig on the Slackware VM and it was hard coded to the address I wanted and DNS was setup correctly and would resolve external sites such as google.com but wouldn’t resolve hardwareasylum.com which was hosted on the host machine.

It was around this time that I started hitting Google looking for a solution and could not find anything related to my particular situation.  In fact most people were complaining they could ping the guest machine but the guest couldn’t get out.  Of course the solution for that is to setup your virtual network to use a physical NIC and that will allow you to access more than just the local machine.  My system was setup that way and I checked and rechecked it many times.

I was about to give up until I tried one final thing.

In the situation where you are running a Hyper-V VM and the guest (VM) can access external sites but cannot contact the host and when the host machine cannot access the guest machine.

Unbind the Guest (VM) IP address from the physical NIC on the Host machine. 

As it turns out there was an IP conflict but, it wasn’t getting recorded in the event logs or preventing the guest machine from accessing the Internet.  When the host machine tried to access the guest it was getting confused as to what IP address to use and I suspect was using the instance that was bound to the physical NIC and not the one running internally on the Guest VM.