Wednesday, May 6, 2009

Howto: Network configuration from the Service Console

Configure service console ip from scratch

If you have screwed up your network configuration and you have lost the connection to your ESX host, here's a couple of commands to configure the network settings from scratch (alternatively, you can try the new console-setup tool that has been introduced as of ESX4.0 U2).

First, delete the service console port group (the vswif) and then delete the virtual switch (typically vSwitch0) so you can start from scratch:

esxcfg-vswif -d vswif0
esxcfg-vswitch -d vSwitch0


(To remove a vMotion portgroup named vMotion: esxcfg-vswitch -D vMotion vSwitch0. If you have an active vMotion portgroup you may recieve the following error when trying to delete the vSwitch: Failed to remove portgroup: vMotion, Error: Unable to delete portgroup "vMotion", for the following reasons: 1 active ports, VM Kernel NIC. In that case, use esxcfg-vmknic to delete active NIC: esxcfg-vmknic -d -p vMotion)

Then create a new vSwitch, attach one or more pnics, add a service console port group (vswif), and configure and ip address for the service console:

esxcfg-vswitch -a vSwitch0

esxcfg-vswitch -L vmnic0 vSwitch0
esxcfg-vswitch -L vmnic1 vSWitch0

esxcfg-vswitch -A 'Service Console' vSwitch0
esxcfg-vswitch -v 55 -p 'Service Console' vSwitch0 (adds VLAN55 to the Service Console)

esxcfg-vswif -a -i 10.44.12.2 -n 255.255.248.0 -p 'Service Console' vswif0

Check your results with:

esxcfg-vswif -l
esxcfg-vswitch -l

Edit the host IP address in the /etc/hosts file (use: #nano -w /etc/hosts)

When done, restart the network with:

service network restart

For changing the default gateway, edit the /etc/sysconfig/network file. Or use the command:

esxcfg-route ip-of-gateway

Reboot the server when done.

See which physical nics are connected to a switch
This command can be handy if you're not quite sure which of your physical nics have in fact been cabled to a switch:

esxcfg-nics -l

Retrieve CDP (Cisco Discovery Protocol) info from service console
With this command you can access CDP info from the COS. This is useful if, for example, your network department has not trunked the proper VLANs through and they want to know exactly which switches and ports are connected to your ESX host.

First enable CDP in both listen and advertise mode (default is only listen, so network dep can't see the nics):

esxcfg-vswitch -B both vSwitch0

vmware-vim-cmd /hostsvc/net/query_networkhint more
(insert 'pipe' before the 'more' command, I can't display it here)

look for the following lines:
device = "vmnic0"
devId = "switchname.bla.com"
portId = "GigabitEthernet9/28" (if it says FastEthernet or just Ethernet it is a 100 Mbit and 10 MBit port and the cable should be changed to a Gigabitethernet port)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.