Enabling LLDP on ESXi standard vSwitches

I developed this script based on a post by Shanon Olsson and thought it might be helpful for someone:

#!/bin/sh
 
switch=vSwitch0
 
# get the list of ports on the vSwitch
ports=$(vsish -e "ls" "net/portsets/$switch/ports")
 
for p in $ports; do
    # search for the UPLINK flag on the port
    c=$(vsish -e "get" "net/portsets/$switch/ports/${p}status" | grep 'flags:.*UPLINK')
    [ -n "$c" ] && uplinks="$uplinks $p"
done
 
for u in $uplinks; do
    # enable LLDP on all the uplink ports
    vsish -e "set" "net/portsets/$switch/ports/${u}lldp/enable" 1
done

#!/bin/sh switch=vSwitch0 # get the list of ports on the vSwitch ports=$(vsish -e "ls" "net/portsets/$switch/ports") for p in $ports; do # search for the UPLINK flag on the port c=$(vsish -e "get" "net/portsets/$switch/ports/${p}status" | grep 'flags:.*UPLINK') [ -n "$c" ] && uplinks="$uplinks $p" done for u in $uplinks; do # enable LLDP on all the uplink ports vsish -e "set" "net/portsets/$switch/ports/${u}lldp/enable" 1 done

Testing

Some plain text.

#!/bin/bash
tee /tmp/foo<<'EOF'
bar
EOF
 
tee /tmp/foo<<'EOF'
bar
EOF

#!/bin/bash tee /tmp/foo&lt;&lt;'EOF' bar EOF tee /tmp/foo<<'EOF' bar EOF

More plain text.

Cisco TAR file format

I needed to upload the device manager HTML files to a Cisco switch separately because I was low on flash space. You can’t download the HTML separately from Cisco (at least not for the 2950 switch I was upgrading) so I had to make the TAR myself.

So I made up a TAR file with the usual tar -cf command and tried to load it, but got a checksum error:

Loading html.tar 
PaxHeader/html (unknown file type)  -- ignored!
%Tar checksum error in ftp://1.2.3.4/html.tar

Turns out that Cisco requires and old format TAR file (compatible with V7 UNIX.) Create the archive with tar -cof and it will work out.

PHP 5.3 database connection problems

My database scripts were all hanging after an upgrade from PHP 5.2.8 to 5.3.1 on Windows. Turns out it’s a problem with the new MySQLnd library that doesn’t like IPv6. You need to comment out the line in C:\Windows\system32\drivers\etc\hosts that resolves ::1 to localhost.

Thanks to Corey Gilmore for documenting it; I figure the more people get it online the quicker it will be for people to find it.