ESX Commands – Summary

It took just about a year. Which shows I need more consistency with my blog (should have been about 1 month). I finally finished a brief explanation of each esxcfg command. My little self study for the VCDX, this is in no way exhaustive.

Make sure to check out other great resources out there:
Simon Long
Harley Stagner
Both good places to start.

Hopefully my VCDX compilation page can help.

ESX Commands: esxcfg-vswif

The esxcfg-vswif command allows you to create and modify Service Console ports and their IP information. Many times I have to change stuff after the install process is complete and the only place is via the direct service console because network communication is not possible. This usually happens when the network team changes a vlan in the middle of the install or they change a subnet. Not to disparage network teams many times I am the network team and the virtualization team.
Create a new vswif:
#first add a port group with esxcfg-vswitch
esxcfg-vswitch -A "Service Console Test" vSwitch-Test
#then use esxcfg-vswif to create a new vswif
esxcfg-vswif -a -i 172.16.50.40 -n 255.255.255.0 -p "Service Console Test" vswif1
#List your vswifs
esxcfg-vswif - l
#Example:
[root@esx3 root]# esxcfg-vswif -l
Name Port Group IP Address Netmask Broadcast Enabled DHCP
vswif0 Service Console 172.16.50.50 255.255.255.0 172.16.50.255 true false
vswif1 Service Console Test172.16.50.40 255.255.255.0 172.16.50.255 true false

Modify your Service Console network information:
esxcfg-vswif -i 172.16.50.41 -n 255.255.255.0 vswif1
#example
[root@esx3 root]# esxcfg-vswif -i 172.16.50.41 -n 255.255.255.0 vswif1
Setting IP config
Nothing to flush.
[root@esx3 root]# esxcfg-vswif -l
Name Port Group IP Address Netmask Broadcast Enabled DHCP
vswif0 Service Console 172.16.50.50 255.255.255.0 172.16.50.255 true false
vswif1 Service Console Test172.16.50.41 255.255.255.0 172.16.50.255 true false

ESX Commands: esxcfg-vswitch

This is a command I use the most often. It is big when I configure Equalogic and MPIO in vSphere. Additionally, many times I show up on site and the network is not configured prior to my arrival. Even if I sent all the configs ahead of time. People like to wait until the last minute. When building the ESX environment then I may build it with the Service Console in the default vlan or in which ever one it is plugged into in the physical network. So oftern the network guy catches up and sets the dot1q trunk and I lose connectivity and I have to go to the console and set the vlans correctly. Like this:
esxcfg-vswitch -v 8 -p "Service Console" vSwitch0
Speaking of iSCSI you will also set your jumbo frames on the vSwitch from this command
esxcfg-vswitch -m 9000 vSwitch1
esxcfg-vswitch
Of course there is a ton more you can do from this command. Here is some man page action for you:

esxcfg-vswitch(8) VMware ESX Manual esxcfg-vswitch(8)

NAME
esxcfg-vswitch - VMware ESX Virtual Switch Configuration tool

SYNOPSIS
esxcfg-vswitch OPTIONS [VSWITCH]

DESCRIPTION
esxcfg-vswitch provides an interface for adding, removing, and modifying virtual switches and their settings. By default,
there is a single virtual switch called vSwitch0.

OPTIONS
-a --add
Add a new virtual switch to the system. It requires a virtual switch name to be provided.

-d --delete
Delete a virtual switch. This will fail if any ports on the virtual switch are still in use by VMkernel networks,
vswifs, or VMs.

-l --list
List all virtual switches and their portgroups.

-L --link
Add an uplink to a virtual switch. This will attach a new unused physical NIC to a virtual switch.

-U --unlink
Remove an uplink from a virtual switch. This will remove a NIC from the uplink list of a virtual switch. If it is
the last uplink, physical network connectivity for that switch will be lost.

-R --restore-uplinks
Restore uplinks for all virtual switches from config file. This will restore all uplinks for each virtual switch from
configurtion file. INTERNAL USE ONLY.

-M --add-pg-uplink
Add an uplink to the list of uplinks for a portgroup

-N --del-pg-uplink
Delete an uplink from the list of uplinks for a portgroup

-P --add-dvp-uplink
Add an uplink to a DVPort on a DVSwitch. Must specify --dvp in the same commnad.

-Q --del-dvp-uplink
Delete an uplink from a DVPort on a DVSwitch. Must specify --dvp in the same commnad.

-p --pg
Provide the name of the portgroup. For the â--vlanâ option, "ALL" can be specified to operate on all portgroups of a
virtual switch.

-V --dvp
Provide the DVPort ID of a DVSwitch.
-v --vlan
Set the VLAN ID for a specific portgroup of a virtuals switch Using the option "0" will disable VLAN for this port-
group. Requires that the --pg option is also specified.

-c --check
Check to see if a virtual switch exists. The program prints a "1" if it exists; otherwise it prints "0".

-A --add-pg
Add a new portgroup to a virtual switch with the given name.

-D --del-pg
Delete a portgroup. This operation will fail if the portgroup is in use.

-C --check-pg
Check whether the specified name is in use for a portgroup. Prints "1" if the name is in use, prints "0" otherwise.

-B --set-cdp
Set the CDP status for a given virtual switch. To set pass one of "down", "listen", "advertise", "both".

-b --get-cdp
Print the current CDP setting for this switch.

-X --set-maxactive
Set the max active uplinks for the virtual switch.

-x --get-maxactive
Get the max active uplinks for the virtual switch.

-m --mtu
Set the MTU for the vswitch. This affects all the NICs attached to the vswitch.

-r --restore
Used at system startup to restore configuration. INTERNAL USE ONLY.

-h --help
Print a simple help message.

EXAMPLES
Add a Virtual Switch:

esxcfg-vswitch --add vSwitch1

Add a Portgroup to vSwitch0:

esxcfg-vswitch --add-pg="New Portgroup" vSwitch0

COPYRIGHT
VMware ESX is Copyright 1998-2009 VMware, Inc. All rights reserved.

VMware ESX 4.0 November 22, 2009 VMware ESX 4.0

Central Syslog Host for ESX – Syslog-ng

Someone may have already written all this, but oh well.

1. Install something free like Ubuntu Server.

2. I use Ubuntu because I like Debian and apt-get. So run:

#apt-get install syslog-ng

Running Syslog-ng gives you more than the standard syslog daemon.

3. Configure syslog-ng to recieve udp logs.

root@hoth:/# cd /etc/syslog-ng/
root@hoth:/etc/syslog-ng# vi syslog-ng.conf

side note: learn VI

Add this after the main source section:

source s_remote {
udp();
};

After the destinations:

destination df_remote { file(“/var/log/remote.$HOST”); };

The $HOST will sort the logs by IP of the server.

And finally add this to the end of the syslog-ng.conf file:

log {
source(s_remote);
destination(df_remote);
};

Now Restart the syslog-ng service

root@hoth:/etc/syslog-ng# service syslog-ng restart

4. Make changes to the ESX syslog config. Thanks to Tooms.dk I have been using syslog-ng so much I needed to find the commands for standard syslog.

1. In the /etc/syslog.conf file add this line “*.* @172.16.0.202” without the ” and change the ip number to your syslog servers ip

2. Restart the syslog service with the command “service syslog restart”

3. Open the ESX server firewall with this command “esxcfg-firewall -o 514,udp,out,syslog” to allow syslog outgoing trafic

4. Tell the ESX firewall to reload the config with this command “esxcfg-firewall -l”

Now you can tail -r /var/log/remote.10.10.10.2 (or whatever your IP is).