- Apply these commands to regular vSwitches:
esxcfg-vswitch -U Note: Unlink and relinking from or to a distributed switch depending on the scenario.#unlink an uplink
esxcfg-vswitch -L# add an uplink - Apply these commands to vNetwork Distributed Switches:
esxcfg-vswitch -Q-V #unlink a DVS uplink
esxcfg-vswitch -P-V #add a DVS uplink - To create the vswif and uplink it to the DVS port:
esxcfg-vswif -a -i-n esxcfg-vswif -a -i 192.168.76.1 -n 255.255.255.0 -V dvSwitch -P 8 vswif0-V -P vswif0
For example:
VirtualizeMe!
Wednesday, May 18, 2011
Configuring vSwitch or vNetwork Distributed Switch from the command line in ESX/ESXi 4.x
Lost access to VM Network and Service Console when Playing with dvSwitch?
I tried adding the physical host to the dvSwitch and it blew up and I lost access to my vCenter VM (VM being the key issue here) because the box only has a single NIC (I also probably ignored a couple of warning dialog boxes as I was distracted doing something else (! pay attention to these things !)
The vCenter node was communicating over the VM Network to my client. which now couldn’t connect into the dvSwitch as I had moved the uplink to the dvSwitch there were no physical NICs to connect with so I was kind of stuck. Connecting directly to the physical ESX host using the VI client worked so I had service console access but it wouldn’t let me remove the pNIC from the dvSwitch and add it back to the traditional vSwitch as I only had a single pNIC. So in the end I had to break out the command line to get access back.
Unlink the pNIC from the dvSwitch: (your vmnic/PortID and dvSwitch names may be different)
esxcfg-vswitch –Q vmnic0 –V 265 dvSwitch
(note there is no -Q=vmnic as the help file would suggest on 1st glance, use a space and not an ‘=’ my esxcfg-* command line-fu was a bit rusty so that caught me out for a while )
Re-link it to a normal vSwitch
esxcfg-vswitch –L vmnic0 vSwitch0
within about 30 seconda all the VM networking came back so I could connect to the vCenter box again.
I then removed the dvSwitch entirely from the host; to do this I had to connect directly to the ESX host using the VI client as there are no options to do it via the UI when connected to vCenter.
vNetwork Distributed PortGroup (dvPortGroup) configuration
- In vCenter, go to Home > Inventory > Networking.
- Right-click on dvPortGroup and click Edit Settings.
- Under dvPortGroup Settings, specify:
- General
- Policies
- Security
- Traffic Shaping
- VLAN
- Teaming and Failover
- Miscellaneous
- Advanced
- Define the following under the General Settings:
- The name of the portgroup
- A description
- The number of ports available
- The type of Port Binding:
- Static Static Binding (Default): means that the dvPort is assigned to the virtual machine at configuration time. When all the ports are booked by virtual machines, it is not possible to connect to any more virtual machines, regardless of whether the connected virtual machines are powered up or not, and an error message is displayed.
- Dynamic Dynamic Binding: means that the dvPort is assigned at the moment of powering the virtual machine up. This option allows for over committing the number of dvPorts.
- None (Ephemeral ports): (Ephemeral Ports or No Binding) this behavior resembles the behavior in the standard vSwitch. If you select this option, the number of ports are automatically set to 0, and the Portgroup allocates one port for each connected virtual machine, up to the maximum number of ports available in the Switch.
- Setting Security:
- Promiscuous mode: Allows machines to see the traffic of all the other machines in the vDS.
- Mac address changes: Allows virtual machines to receive frames with a Mac Address that is different from the one configured in the VMX.
- Forged Transmits: Allows virtual machines to send frames with a Mac Address that is different from the one specified in the VMX.
- Traffic Shaping policies:
Notes: Allows you to define ingress and egress traffic shaping.
Ingress shaping is a new feature, and available only with dvSwitch (not on vSwitch).
Traffic Shaping concepts:- Average Bandwidth: Target traffic rate cap that the switch tries to enforce. Every time a client uses less than the defined Average Bandwidth, credit builds up.
- Peak Bandwidth: Extra bandwidth available, above the Average Bandwidth, for a short burst. The availability of the burst depends on credit accumulated so far.
- Burst Size: Amount of traffic that can be transmitted or received at Peak speed (Combining Peak Bandwidth and Burst Size you can calculate the maximum allowed time for the burst.
- VLAN EST Policies:
Note: Allows you to specify the VLAN behavior of only the dvSwitch.- EST – External Switch Tagging
- NONE: Physical equivalent to: No VLAN Tagging
- Standard vSwitch equivalent to: VLAN ID option set to 0
- VLAN VST Policies:
- VST – Virtual Switch Tagging
- VLAN: Physical equivalent to: VLAN in Access/Untagged mode
- Standard vSwitch equivalent to: VLAN ID option
- VLAN ID 4095 is not allowed here
- VGT Policies:
- VGT – VLAN Guest Tagging
- VLAN Trunking: Physical equivalent to: VLAN in Trunk/Tagged mode
- Standard vSwitch equivalent to: VLAN ID set to 4095
- vDS Only: option to specify the range of VLANs to trunk, to improve security
- PVLAN Policies:
- PVLAN Physical equivalent to: PVLAN
- Standard vSwitch equivalent to: Does not exist
- PVLAN option to specify which Primary and Secondary VLAN to use (Selecting from the list defined in the Switch)
- Teaming and Failover Policies:
- Load Balancing
- Failover detection
- Notify Switches
- Failback
- Failover order
- Specific Uplink usage
- Miscellaneous Policies:
- Allows you to block all the dvPorts of the dvPortgroup.
- The dvPortgroup Advanced subcategory is different from dvSwitch:
- It allows each single dvPort to override the settings of the dvPortgroup.
- Clicking Edit Override Setting the VI Admin can also specify which properties to allow/not allow to be overridden at lower levels.
Enabling SSH on ESXi 3.5 or 4 (VSphere)
Here is how its done:
1. At the start up screen (Management Console) press ALT+F1 and a console screen will come up
2. Type unsupported (you will not see the text) and press Enter
3. You'll see "Technical Support Mode" and a prompt for a password; simply type in your root password
4. If everything is successful you will be given a shell "#"
5. Type in vi /etc/inetd.conf
6. The config file will come up on the screen and now just scroll down until you see "#SSH"
7. Press the "Insert" button on your keyboard and remove the # (This will uncomment the function)
8. Now press "ESC" button and type :wq (this will write and quit your editing session)
9. Now type in ps -a | grep inetd (this will find the process for inetd)
10. You should see the PID for "busybox"/"inetd" (the number will be different for everyone)
11. Type kill (and the PID number from the last step) and this will stop the inetd process
12. Type cd /etc
13. Type ./services.sh restart (this will restart the management services)
14. Now perform a clean reboot of your ESXi machine by typing ALT+F2 to get back to the management screen
15. Press F12 to shutdown/restart and restart (wait for you machine to come back up)
16. Now you should be able to log in with SSH (putty) and SCP (WinSCP)
Vmotion is Disabled after upgrade
Here is a quick fix for those experiencing a problem using VMotion after upgrading from ESX Server 2.5 to ESX Server 3.5
In some cases after this upgrade is done VMotion is disabled and warm migrations are not possible. The solution is to re-enable VMotion on the host.
Re-enable VMotion on the host:
- Select the host in VI Client and navigate to the Networking section of its Configuration tab.
- Click the Properties link for the switch associated with the VMkernel port.
- In the switch Properties dialog box, select the appropriate network label and click Edit.
- Select the VMotion Enabled checkbox and click OK.
Search for VM Snapshots from the Service Console
It may not be the fanciest of methods, but probably the quickest way to find VM snapshots is to use the ls command from the ESX Service Console. By piping the output with grep to find files with the snapshot extension, .vmsn, and using the recursive switch you can scan all the VMFS LUNs visible to an ESX host. That’s so simple it hurts!
To use the ls command to find snapshots do the following:
- Log in to the service console (use putty or mRemote for remote log in)
- Query for the snap shot files in the VMFS volumes
#ls -Ral /vmfs/volumes/* |grep .vmsn
Create USB Drive to Install VMware ESX Server
- Plug in your USB flash disk and format it in dos using the following command: FORMAT I: /FS:FAT
- From Windows Explorer, find the boot.iso file in the /images directory on the ESX 3.x CD-ROM. Copy boot.iso into a temporary directory on your hard drive.
- Using your ISO extraction or mount program, extract the contents of the boot.iso file to your USB flash drive.
- Delete the isolinux.bin and updatecd.cfg files from the USB disk.
- Rename the isolinux.cfg file on the USB flash disk to syslinux.cfg
- Using WordPad (not Notepad), open the syslinux.cfg file and add the keyword usb to the end of every line that begins with append. Here's what the file should look like when you're done:
- default esx
- prompt 1
- timeout 600
- display boot.msg
- F1 boot.msg
- F7 snake.msg
- label debug
- kernel vmlinuz
- append initrd=initrd.img noapic nomediacheck debug usb
- kernel vmlinuz
- label esx
- kernel vmlinuz
- append initrd=initrd.img usb
- kernel vmlinuz
- label text
- kernel vmlinuz
- append initrd=initrd.img text usb
- kernel vmlinuz
- label expert
- kernel vmlinuz
- append expert initrd=initrd.img usb
- kernel vmlinuz
- label ks
- kernel vmlinuz
- append ks initrd=initrd.img usb
- kernel vmlinuz
- label lowres
- kernel vmlinuz
- append initrd=initrd.img lowres usb
- kernel vmlinuz
- default esx
- Extract the syslinux.zip file into another temporary directory on your hard drive.
- Open up a command prompt and navigate into the win32 directory. For example: C:\temp\syslinux-3.36\win32
- Now, run the syslinux program to apply the boot loader and boot sector to the USB flash drive: syslinux -s –ma I:
- Copy the ESX 3.x ISO image onto the USB drive root
- Confirm that your USB flash drive contains the following files:
- boot.cat
- boot.msg
- initrd.img
- snake.msg
- splash.lss
- vmlinuz
- syslinux.cfg
- esx-X.iso
- boot.cat
- Your ready to go, ensure your bios on the server you want to install too is setup to boot from USB or select USB from the alternate boot menu.
- The ESX installer will detect the USB device and whatever SCSI / disk controllers you have. When the installer asks you what the installation source will be, choose Hard Disk.
- You will need to choose the right disk device (ie. /dev/sda, /dev/sdb) that corresponds to your USB disk. Chances are it will be /dev/sdb.
- Finally, the installer will ask you what directory to find the ESX installation CD image in. Just use / and it will find the .ISO image for you.