dwchan
Enthusiast
Enthusiast

what is the best practice way to change esx server from DHCP to static IP after the server is up

we are deploying our new ESX environment using HP Rapid Deploy and HP Blade BL servers. The deployment process works quite well, except it deploy all server in DHCP mode. In short, after the server is up and running, what is the best practice (which files to edit) to change the service over from dhcp to static IP? I want to make sure I didn't miss anything that suppose to get edited

dwc

0 Kudos
9 Replies

Hi,

you need to file following files

/etc/sysconfig/network-scripts/vswif0

add the lines the following way

BOOTPROTO=static

IPADDR=10.0.0.50

NETMASK=255.0.0.0

ONBOOT=yes

BROADCAST=10.255.255.255

I am assuming that you already created a vswitch and this nic is used for service console.

then "service network restart"

(this will reset nics used by service console)

regards

santhosh

0 Kudos
petedr
Virtuoso
Virtuoso

You can also run

esxcfg-vswif -i x.x.x.x vswif0 and make sure you also update /etc/hosts to reflect the new IP.

there is a kb article on changing the IP

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=430949...

www.thevirtualheadline.com www.liquidwarelabs.com
0 Kudos
Texiwill
Leadership
Leadership

Hello,

The best way or the supported way, both methods discussed work. Note that the first method is a Linux specific method that will not save the appropriate data within the configuration files. Use of esxcfg-vswif is the suggested method as it will store things appropriately. Also, be sure you are logged in at the console as you will loose your network connections once you cycle the network adapter.

esxcfg-vswif
ifdown vswif0
ifup vswif0

Best regards,

Edward L. Haletky, author of the forthcoming 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', publishing January 2008, Copyright 2008 Pearson Education. Available on Rough Cuts at http://safari.informit.com/9780132302074

--
Edward L. Haletky
vExpert XIII: 2009-2021,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos
Schorschi
Expert
Expert

The only thing that esxcfg-vswif does not do is change the default gateway, I wish it did.

0 Kudos
Texiwill
Leadership
Leadership

Hello,

You use 'esxcfg-route' to do that.

Best regards,

Edward L. Haletky, author of the forthcoming 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', publishing January 2008, Copyright 2008 Pearson Education. Available on Rough Cuts at http://safari.informit.com/9780132302074

--
Edward L. Haletky
vExpert XIII: 2009-2021,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos
dwchan
Enthusiast
Enthusiast

How so, does esxcfg-route change the setting inside /etc/sysconfig/network?

0 Kudos
moberle
Contributor
Contributor

It doesnt. You have to edit the gateway parameters in that file. The esxcfg-route command sets the vmotion subnet's gateway. You need to do both.

I do both in my %post processing.

0 Kudos
Schorschi
Expert
Expert

I was suggesting that esxcfg-vswif call esxcfg-route of you do change the NIC IP information, the fact that esxcfg-vswif options do not allow change of the default gateway has always bugged me. You can change everything about the COS NIC but the DG value. I understand what VMware did and why, I just think it would have been to have say a --gateway option with esxcfg-vswif.

0 Kudos
Texiwill
Leadership
Leadership

Hello,

I once used esxcfg-route to change the default gateway, but that was v3 beta.... Changing the value in /etc/sysconfig/network is one option, however, you can setup a per NIC gateway as well by editting the /etc/sysconfig/network-scripts/ifcfg-vswifXXX files as well. Or you can add to the /etc/rc.d/rc.local file some 'ip route' commands, or add lines to /etc/sysconfig/static-routes as well. There are quite a few ways to dress the penguin on this one. If you only have one vswif device, I suggest you modify /etc/sysconfig/network using something like:

grep -v GATEWAY= /etc/sysconfig/network > /tmp/network
echo "GATEWAY=newDefGateway" >> /tmp/network
cp /tmp/network /etc/sysconfig/network

Where newDefGateway is the IP address of the gateway. You could use awk, sed, and a number of other tools using complex scripting or regular expressions as well. Note the 'GATEWAY=' has a trailing = in the grep -v line, otherwise you get too many lines removed.

Best regards,

Edward L. Haletky

VMware Communities User Moderator

====

Author of the forthcoming 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', publishing January 2008, Copyright 2008 Pearson Education. Available on Rough Cuts at http://safari.informit.com/9780132302074

--
Edward L. Haletky
vExpert XIII: 2009-2021,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos