Mittwoch, 30. November 2011

Accessing the host network from a KVM guest

KVM guests can be created and installed very easy by the use of a NAT network. However, with that you cannot access the network on your host as both networks are working in a different network.
The solution is to install the bridge-utils and configure a tun/tap network, which will allow the network access to the host system.

Here an example for Ubuntu 12.04:

  • installing the needed packages
sudo apt-get install bridge-utils
sudo apt-get install uml-utilities

  • make a backup of your original network configuration file
sudo cp /etc/network/interfaces /etc/network/interfaces.backup

  • edit the network configuration file similar to this

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto tap0
iface tap0 inet static
pre-up tunctl -u $USER -t $IFACE
post-down tunctl -d $IFACE

auto br0
iface br0 inet static
bridge_ports eth0 tap0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
  •   restart the network
 sudo /etc/init.d/networking restart

  • start the KVM guest for example with a similar shell script like this:
/usr/bin/kvm  -soundhw es1370 -k de -vga vmware \

-enable-kvm -m 3072 -localtime \
-hda "/vm/vm-images/ubuntu1004_32b"  \
-boot once=c,menu=off \
-net nic,vlan=0,macaddr=52:54:00:7b:95:22 \
-net tap,vlan=0,ifname=tap0,script=no \
-name "Ubuntu 10.04 32B" $*

 voilá :-)

Donnerstag, 6. Oktober 2011

terminating telnet

Terminating telnet is quite easy. Just follow, what telnet itself writes on screen:

Escape character is '^]'.

But, hey, what does that mean? This is the defined ASCII character for "Escape Sequence", which is in value 0x1B or 27 in decimal. You might think that terminating telnet would be possible by just using the "ESC" key on your keyboard, which is exactly the keyvalue. But this key-press will not be recognised by the telnet session.

The solution is to generate the escape-sequence with the following keys ("+" means using the keys simultaneously):


Note: This is how it works on a german keyboard. It might be different (in case of ALT GR) on other language maps.

Mittwoch, 16. Februar 2011

sudo doesn't export LD_LIBRARY_PATH

Sometimes it is desired that you put your own shared libraries into an own directory to keep your system's libraries paths clean. There's nothing to say against it. For this reason, an environment variable can be defined, which points to your library path: LD_LIBRARY_PATH.
Normally you define your path for example in /etc/profile and it is then available for every user.
However, you can find yourself surprised, that calling your application as user root by using the 'sudo' command will fail. The reason is quite simple: The sudo command doesn't export your LD_LIBRARY_PATH!

This can be proven by doing a 'sudo printenv'. Also doing a sudo -V as superuser will show you, that every environment variable beginning with 'LD_*' will not be forwarded.

The only workaround I found for this is the use of the sudo command with an alias.

In your ~/.bashrc file add following alias:

# because sudo doesn't export LD_LIBRARY_PATH for our apps
alias sudo='sudo env LD_LIBRARY_PATH=/usr/local/lib/your_path'

Save this file and source it. Afterwards your sudo command can be used conveniently.