Exposing VMware linux server image's IP address to local area connection
Recently, we decided to move our SOHO RHEL server at office to a more permanent location. After powering it on in its new location, we discovered the network was not working. We used to log in to a static IP address of the device using ssh via PuTTY from our laptops to get into the server environment. We hadn't started doing a port configuration system yet, so it must have been something within the physical machine itself.
When I joined the team the entire thing was already setup so I hadn't got a chance to look at how we were working with it so far, and this was an opportunity for me to go and take a look at it.
Here's how we were using our server.
A RedHat Linux Server Disk Image file running on VMWare Pro installed on a Windows 10 machine. First I thought it was a disk image issue and removed all image and configuration files from VMWare. After re-adding the disk image file the system booted perfectly but we weren't getting the previous static IP address as before. I opened Network Settings on Windows 10(host) and setup Ethernet to use static IP address as has been described here. Ping worked fine from my laptop but I still wasn't in the RHEL server (image) yet.
Next, I opened the image's Settings from VMWare application and changed the type of network to NAT mode. I booted in the image to see if it worked. This didn't solve the problem as the server image setup another IP address to communicate with the host itself, and which wasn't accessible by other computers in the same LAN. So, I decided to look into the network configuration of server image itself. First i looked at the name of the interface (eth0) with ifconfig, and then I went to the location /etc/sysconfig/network-scripts and searched for the corresponding configuration for eth0. Here, I setup the static IP address similar to the one I setup in host as follows :
IPADDR = 192.168.1.x(x being the static address that was used for the server)
I kept all existing config as it is. More settings can be found here. Then I restarted the network as a superuser using
service network restart
I now checked the IP address of both host and server image, which were now configured to use the same static IP address. However, I could ping to the host but not to the RHEL server even though the server image was getting the same IP address. Also, at this point the internet in the server image stopped working as well.
After exploring around the network for a while, I finally figured out the issue. Turns out VMware creates virtual network adapters for each of the network modes, and we don't necessarily need NAT mode to expose the image to local network. Since both the host and server image were set to same static address, there was IP conflict so the network didn't work in the server image. I quickly changed the host IP back to dynamic, and changed network mode in VMware to Bridged Mode. Then, I made sure the VMware virtual network adapter configuration for VMnet0 were set correctly to bridge mode and the defined subnet was same as my LAN. There are also other virtual adapters such as VMnet1 for host-only and VMnet8 for NAT. Now the Ethernet in my host Windows 10 can take any IP from network DHCP but regardless of this IP, my server image always takes the static IP address that I set in its configuration file, thus I can easily ssh into it, which was possible due to VMnet0 virtual adapter provided by VMware.
Future plan : Explore further on other virtual network adapters configurations. Also I am thinking about maintaining an address reservation list in the router itself so that we do not need to maintain configuration in each device, like we did for this server image.
When I joined the team the entire thing was already setup so I hadn't got a chance to look at how we were working with it so far, and this was an opportunity for me to go and take a look at it.
Here's how we were using our server.
A RedHat Linux Server Disk Image file running on VMWare Pro installed on a Windows 10 machine. First I thought it was a disk image issue and removed all image and configuration files from VMWare. After re-adding the disk image file the system booted perfectly but we weren't getting the previous static IP address as before. I opened Network Settings on Windows 10(host) and setup Ethernet to use static IP address as has been described here. Ping worked fine from my laptop but I still wasn't in the RHEL server (image) yet.
Next, I opened the image's Settings from VMWare application and changed the type of network to NAT mode. I booted in the image to see if it worked. This didn't solve the problem as the server image setup another IP address to communicate with the host itself, and which wasn't accessible by other computers in the same LAN. So, I decided to look into the network configuration of server image itself. First i looked at the name of the interface (eth0) with ifconfig, and then I went to the location /etc/sysconfig/network-scripts and searched for the corresponding configuration for eth0. Here, I setup the static IP address similar to the one I setup in host as follows :
IPADDR = 192.168.1.x(x being the static address that was used for the server)
I kept all existing config as it is. More settings can be found here. Then I restarted the network as a superuser using
service network restart
I now checked the IP address of both host and server image, which were now configured to use the same static IP address. However, I could ping to the host but not to the RHEL server even though the server image was getting the same IP address. Also, at this point the internet in the server image stopped working as well.
After exploring around the network for a while, I finally figured out the issue. Turns out VMware creates virtual network adapters for each of the network modes, and we don't necessarily need NAT mode to expose the image to local network. Since both the host and server image were set to same static address, there was IP conflict so the network didn't work in the server image. I quickly changed the host IP back to dynamic, and changed network mode in VMware to Bridged Mode. Then, I made sure the VMware virtual network adapter configuration for VMnet0 were set correctly to bridge mode and the defined subnet was same as my LAN. There are also other virtual adapters such as VMnet1 for host-only and VMnet8 for NAT. Now the Ethernet in my host Windows 10 can take any IP from network DHCP but regardless of this IP, my server image always takes the static IP address that I set in its configuration file, thus I can easily ssh into it, which was possible due to VMnet0 virtual adapter provided by VMware.
Future plan : Explore further on other virtual network adapters configurations. Also I am thinking about maintaining an address reservation list in the router itself so that we do not need to maintain configuration in each device, like we did for this server image.
Comments
Post a Comment