Archive for June, 2012

Set up a virtual network in VMware ESX

Set up a virtual network in VMware ESXi

The following steps show how to set up a virtual network environment for testing. With this method, (v)network adapters of (v)machines are plugged into (v)networks. The nodes inside the network are all virtual machines and need to be configured properly.

About ESXi

In this way a set of networks can be defined. To make things a bit more clear here is a bit more explanation about ESXi:

  1. ESXi describes an infrastructure of the network and virtual machines inside the network.
  2. Networks can be seen as physically interconnected network (e.g. some switches connected to each other, providing ports to plug in network cards)
  3. A network card is plugged into a single network.
  4. Virtual machines can have 0..* network cards. (machines with more than 1 card are typically routers)

Define networks

In OS:

  1. Download VMWare ESXi iso file.

In VMWare player:

  1. Create new VM (select ISO file)
  2. Install ESXi. Make sure to use large enough disk size (default 40 GB) to hold VMs plugged into the virtual network.
  3. Boot ESXi

In Browser:

  1. Visit the “manage” url displayed by ESXi and download the vSphere Client

In OS:

  1. Install vSphere client
  2. Start vSphere Client

In vSphere Client (add some networks):

  1. Click Home → Click Inventory → On left, click your ESXi IP → Click Configuration tab → Click Networking
  2. Click Add Networking…
  3. Select Virtual Machine → Click Next → Select Create a vSphere standard switch → Click Next
  4. Type a a name for your network (e.g. network1)
  5. Click Next → Click Finish
  6. Add more networks to your liking

We have now defined a set of networks. We can now define virtual machines with network cards that can plug into these networks. Now you can either create or import existing Virtual Machines to your virtual network(s).

Creating virtual machines

In vSphere Client (home)

  1. Click Home → Click Inventory → On left, click your ESXi IP → Click Virtual Machines tab
  2. Right click on the white area → Click New virtual machine…

From here you can create a new virtual machine on the ESXi data store (this is the “disk” on your ESXi machine). Note that during network configuration you can select which network card is connected to which network. Now we have a VM plugged. However, before using it we need to install an OS.

In vSphere Client (home) we first need to upload the installation files (e.g. iso)

  1. Click Home → Click Inventory → Click Configuration tab → Click Storage
  2. Right click your data store → Click Browse datastore…
  3. Navigate to the location you want to upload to
  4. Click the upload button in the toolbar (disk with up arrow) → Click Upload file and select the file you want to upload

In vSphere Client

  1. Click Home → Click Inventory → On left, click your ESXi IP → Click Vritual Machines tab
  2. Right click your VM → Click Edit settings
  3. Click CD drive → Select datastore ISO file → Check Connect at power on → Click OK
  4. Right click your VM → Click Power → Click Power on
  5. Right click your VM → Click Open console

In the console you can control your VM as you like. (normal machine, router/gateway)

Using existing (player) virtual machines in ESXi

If you need to impport existing virtual machines in your test setup you can do so as follows. The following shows an example how to import an existing VMware player image into your VMware ESXi server. In Browser:

  1. Download VMWare Converter Standalone

In OS:

  1. Install the VMWare Converter

In VMWare Converter

  1. Click Convert machine → Select your source type VMware Workstation or other VMware virtual machine → Select your source Virtual machine file → Click Next
  2. Select destination type VMware Infrastructure virtual machine → Enter server ip or name,user name and password → Click next
  3. Enter a virtual machine name → Click next → Click next
  4. Customize hardware options if required → Click next → Click finish

After this wizard, the virtual machine file is automatically transferred to and registered in your ESXi server. We can now plug the imported VM into our virtual networks.

In vSphere Client

  1. Click Home → Click Inventory → On left, click your ESXi IP → Click Virtual Machines tab
  2. Right click on your VM → Click Edit settings
  3. Click the network adapter you want to plug
  4. In the Network label section select the network you want to plug the adapter into

Repeat the above instructions for all network cards and click ok. Now we are ready to boot and control the new VM.

In vSphere Client

  1. Right click your VM → Click Power → Click Power on
  2. Right click your VM → Click Open console

APPENDIX: Setting up VM to use as a router

Alpine linux is a linux distribution which allows quick configuration of a router or simple pingable node for testing. This distribution can be run from an ISO file and doesn’t need to be installed.

A machine with multiple network cards can reach other machines in the networks it is directly plugged into. For example a machine with two network cards (ip 101.0.0.1) is plugged into 101.0.0.0/8 and 102.0.0.0/8 networks. The machine cannot directly connect to nodes in the 103.0.0.0/8 network. However, maybe there is another machine (a gateway) which can forward the data to the correct machine. Say this gateway is 101.0.0.254.

The same can be done with IPv6, but instead of addresses such as 101.0.0.1 we can use 101::1 as IPv6 address.

Configuring our machine

Now the only thing our machine needs to know is that if it wants to reach the 103.0.0.0/8 network, gateway is 102.0.0.254, the gateway will be able to forward data to the final destination. To do this add the following on the machine:

Linux


ip route add 103/8 via 102.0.0.254

ip -6 route add 103::/64 via 102::254

OpenBSD

route add -net 103.0.0.0/8 102.0.0.254
route add -net 103.0.0.0 -netmask 255.0.0.0 102.0.0.254           # IPv4 alternative notation
route add -inet6 103:: -prefixlen 64 102::254

The above is a custom routing table entry specifying explicitly which gateway to use to reach a specific network. After adding it it can access the 101.0.0.0/8 network (directly accessible), the 102.0.0./8 network (directly accessible), and the 103.0.0.0/8 network (via the specified gateway).

The machine will attempt to access any other networks which are not defined explicitly via the default gateway (say 101.0.0.253). This default gateway is often a router that allows you to access your ISP to allow internet communication. The default gateway can now be be set.

In Linux this is done as follows:


route add default gw 101.0.0.254

route -A inet6 add default gw 101::254

In OpenBSD this is done as follows:


route add default 101.0.0.254

Configuring a gateway/router

If we use an alpine linux router configuration, we can set it up as follows:

  1. Mount the alpine linux iso file
  2. Make sure that your virtual machine has two network cards, eth0 plugged into 101.0.0.0/8 and eth1 plugged into 102.0.0.0/8

IPv4 configuration

Now we can configure the network interfaces of the router using:

ifconfig eth0 up 102.0.0.254
ifconfig eth1 up 103.0.0.254

Now we must make sure that the router will forward network traffic between networks:

 echo 1 > /proc/sys/net/ipv4/ip_forward 

IPv6 configuration

 
modprobe ipv6
ifconfig eth0 up
ifconfig eth1 up
ip -6 addr add 102::254/64 dev eth0
ip -6 addr add 103::254/64 dev eth1
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding

Configuring the PingTest machine

With the setup in the previous sections, ping requests should arrive at the PingTest machine. This can be verified by using tcpdump (see section below). However, the ping will still fail, because the PingTest machine does not know how to send data back to the 102/8 network. To to this, we need to set up the correct routing information:

modprobe ipv6
ifconfig eth0 up 103.0.0.1
ip -6 addr add 103::1/64 dev eth0
ip route add 101/8 via 103.0.0.254
ip -6 route add 101::/64 via 103::254

Inspecting traffic and troubleshoot problems

Sometimes setting up such a setup will not work at once, but by using the following commands you can inspect which traffic arrives at certain machines.

apk add tcpdump
tcpdump -n icmp  # For checking IPv4
tcpdump -n icmp6 # Fox checking IPv6

Setting up a DHCP server to hand out IP addresses

If you need to obtain an IP via DHCP you can install and set up a DHCP server.

setup-alpine # Needed for the dhcp startup script on alpine. This will re-prompt you some questions about your network configuration, but you can answer all questions except IP configuration with the default settings
apk add dhcp
apk add vim   # Editor, you can also use nano instead
vim /etc/conf.d/dhcpd

Specify the interface on which the DHCP server should listen

DHCPD_IFACE = "eth0"

Now we edit the server configuration file

vim /etc/dhcp/dhcpd.conf

A configuration with a single subnet declaration is sufficient

subnet 102.0.0.0 netmask 255.0.0.0 {
range 102.0.0.2 102.0.0.20;
}

This configuration will hand out IP addresses between 102.0.0.2 and 102.0.0.20.

Sunday, June 17th, 2012 Uncategorized No Comments

Using gnome network manager when using window manager instead of desktop environment

When using a window manager such as awesomewm instead of a full-fledged desktop environment such as gnome, you may have problems connecting to wireless networks.

To use the gnome network manager in your environment, add the following command line to your startup applications:

nm-applet --sm-disable

Via:

Sunday, June 17th, 2012 Uncategorized No Comments

Overview of CSS compatibility per browser

Whenever you do some cross-browser CSS development, this overview page on CSS feature compatibility per browser is quite handy:

http://www.quirksmode.org/css/contents.html

Wednesday, June 6th, 2012 Uncategorized No Comments

Automate Konsole

It is possible to automatically execute commands in a currently open console session. To do this first check (with another terminal) which console session is currently open:

 qdbus org.kde.konsole /Konsole currentSession 

You can use the following shell script to execute a command inside that console session:

COMMAND="ls"
SESSION=1
qdbus org.kde.konsole /Sessions/%{SESSION} sendText "^A^K^L${COMMAND}^M"

Note that the above ^A, ^K, ^L, and ^M are special characters you have to insert into your script properly.

The ^A^K^L will clear the current command and the screen. ^M will press enter, executing the command.

Tuesday, June 5th, 2012 Uncategorized 1 Comment

Make use of NVIDIA optimus technology on Ubuntu 12.04

NVIDIA Optimus can help extending battery life by disabling your dedicated NVIDIA video card. In this way you can do most of your office work with your less power-hungry integrated video chip and only fire up the dedicated card when required for graphics-heavy applications or games.

Currently NVIDIA officially only supports this technology for Windows 7, but the bumblebee project brings this battery life optimization to linux.

If you have any NVIDIA drivers already installed, uninstall them:

sudo apt-get purge nvidia-current

Reboot your system after uninstallation of the driver.

To install in Ubuntu 12.04 the following three commands should suffice:

sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bbswitch-dkms bumblebee bumblebee-nvidia virtualgl-libs:i386 libgl1-mesa-glx:i386 libc6:i386
sudo usermod -a -G bumblebee $USER

That’s it, now you can enjoy longer battery life, less heat, and less cooler noise from your system.

To test whether everything works you can run

glxspheres

This should use your integrated video card by default. Note the frames per second you see.

Now if we want an application to use the internal one, run

optirun glxspheres

This should use your dedicated video card and yield better performance than the previous run.

It’s possible that the default xorg monitor configuration for your NVIDIA card is not correct yet. In this case you may need to adjust the ConnectedMonitor option in /etc/bumblebee/xorg.conf.nvidia. In my case this was “DFP” and needed to be changed to “CRT-0”.

Via: Nvidia Optimus on Ubuntu.

Saturday, June 2nd, 2012 Uncategorized 1 Comment