Monday, June 25, 2007

VMware: Changing the IP Address of Service Console in ESX 3.x

To change the IP address of the ESX 3.x host, you need to change the configuration of the vswif. By default this is vswif0 and this is assumed in this document.
Login to the service console with root permissions, either by using root or doing a su - to get the permissions.

Once in the service console run the command "esxcfg-vswif -d vswif0". This command deletes the existing vswif0. Don't worry if you get a message about nothing to flush.

Then you need to run the command to change the ip address, subnet mask and broadcast address. They are also specified in that order when the command is given. An example command is below.
"esxcfg-vswif -a vswif0 -p Service\ Console -i -n -b"
In this command the -a switch is to add a vswif, the \ in the Service\ Console is deliberate, the -i is the ip address, the -n is the netmask and the -b is the broadcast address.

You now need to change your default gateway, you can do this by editing the network file located at /etc/sysconfig/network. To do this at the command prompt, follow the steps below.
"cd /etc/sysconfig", then
"vi network"
Then while in vi, go to the location of the default gateway using the arrow keys. Hit "i" which will perform an insert and change the default gateway to your liking.
(Optional: yo can edit the host name too).
Hit the escape key twice to exit insert mode.type ":wq!" to write (i.e save) and quit.
At this point you can run some commands to restart the vmware management, but I prefer to restart the server and will recommend you do that. Once the server comes up there are a few things that still need to be done for management in virtualcenter.

Open a remote console to your virtualcenter server, do a ping to make sure the ESX host is pingable after the IP change. Make sure you are seeing the new IP address and it is assumed you have already changed that in DNS. If you are seeing the host correctly, open virtualcenter and disconnect then reconnect the host.

Once the host is connected in virtualcenter we need to change a few bits of configuration information, namely the vmkernel ip address, subnet and gateway. This is so we can vmotion correctly. Click on your host and bring up the configuration tab. Select networking and then properties on the vitual switch.

Select your vmkernel and hit the edit button. Change your ip address here for vmotion and subnet mask. You will not be able to change the default gateway until you hit ok and go back in. Once you have selected ok, then hit edit again on the vmkernel. Select the edit button on the default gateway and change the default gateway on the menu that appears. Select ok, ok again and then close.

Please note all the commands in this document should be used without the "".