October 03, 2013

Accessing vSphere Web Client via SOCKS proxy

vSphere Web Client is a very nice and usable alternative to a standard vSphere Infrastructure Client. The first one is a cross-platform solution, when the second can be run only from Windows machines and need a license to install / or a remote desktop connection to use from the customer (which is usually slow)

When someone wants to open VM Console in the vSphere Web Client under Linux (via SOCKS proxy), here is a nice way I have found after doing some debugging & tracing.

Assume you have following IP to vSphere

10.60.0.10 is vCenter
10.60.0.12 is ESX

vSphere Web Client is at https://10.60.0.10:9443/vsphere-client address.

To access the 10.60.0.0/16 you need to go via 9.100.200.210:1080 SOCKS proxy

Below is the solution of getting a “straight” access to the vCenter

Add Virtual IPs (em1 is my main network interface)

# ifconfig em1 add 10.60.0.12
# ifconfig em1 add 10.60.0.10

Define vCenter IP in /etc/hosts

[root@localhost ~]# grep '10\.30' /etc/hosts
10.60.0.10    vcenter.esx.lab.local

Create following port forwards (ncat you can find in the “nmap-ncat” package)

# ncat -k -l 10.60.0.12 902 --sh-exec "ncat -v --proxy-type socks4 --proxy 9.100.200.210:1080 10.60.0.12 902"
# ncat -k -l 10.60.0.10 9443 --sh-exec "ncat -v --proxy-type socks4 --proxy 9.100.200.210:1080 10.60.0.10 9443"
# ncat -k -l 10.60.0.10 443 --sh-exec "ncat -v --proxy-type socks4 --proxy 9.100.200.210:1080 10.60.0.10 443"

Now you can “directly” access to the vCenter / ESX using original IP.

Go to “https://10.60.0.10:9443/vsphere-client” in your favorite browser

[arno@localhost ~]$ firefox
...
...
2013-05-16 10:53:34.912 [/build/mts/release/bora-781747/bora/apps/vmplayer/npplugin/linux/VmrcDelegateImpl.cc:1576]: ReceiveVmrcCommand(initComplete, 0)
2013-05-16 10:53:34.912 [/build/mts/release/bora-781747/bora/apps/vmplayer/npplugin/linux/VmrcDelegateImpl.cc:340]: startup succeeded
2013-05-16 10:53:35.649 [/build/mts/release/bora-781747/bora/apps/vmplayer/npplugin/linux/VmrcDelegateImpl.cc:1576]: ReceiveVmrcCommand(2, 6)
2013-05-16 10:53:35.670 [/build/mts/release/bora-781747/bora/apps/vmplayer/npplugin/linux/VmrcDelegateImpl.cc:1651]: conn state -- 2 / vcenter.esx.lab.local:443 /  / vm-418 / true / Connection successful.
2013-05-16 10:53:35.918 [/build/mts/release/bora-781747/bora/apps/vmplayer/npplugin/linux/VmrcDelegateImpl.cc:1576]: ReceiveVmrcCommand(gotConnState, 1)
2013-05-16 10:53:35.936 [/build/mts/release/bora-781747/bora/apps/vmplayer/npplugin/linux/VmrcDelegateImpl.cc:1576]: ReceiveVmrcCommand(4, 2)
...

VM Console was successfully opened!