Categories
Linux / Gentoo Linux

Networking for KVM with CentOS 5.5

I’ve found numerous tutorials to set up KVM with CentOS 5.5. Some refer to the Red Hat guides, which are useless in my opinion if you are not using KVM in a large server park, others come up with scripts to set up networking.

I kept searching and trying configurations until I finally found one that works. Note that among problems you might encounter is the one that plagued me for months: CentOS is attempting to bring up the virtual device for LAN access on the host before bringing up the physical interface, this fails and prevents all networking and dependencies from starting properly.

To set up the bridge devices for KVM and the host (something which is done only once to ‘wire’ your virtual network instide the bridge) look here. Most of the guide is still relevant even if they refer to the Red Hat documentation (which is about Red Hats cloud virtualisation platform and not a single server running KVM).

Use a configuration like this for proper KVM networking under CentOS, Red Hat and probably even Fedora.

1. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 to contain something like this:

1
2
3
4
5
6
7
# /etc/sysconfig/network-scripts/ifcfg-eth0 - the physical NIC which will not be used directly
DEVICE=eth0
TYPE=Ethernet
HWADDR=00:23:B3:16:3F:00
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no

The “NM_CONTROLLED” bit seems to originate from Fedora 12/13, CentOS might ignore it altogether so you could leave it out.

2. Edit /etc/sysconfig/network-scripts/ifcfg-br0 to restore network access for your host machine:

1
2
3
4
5
6
# /etc/sysconfig/network-scripts/ifcfg-br0 - Bridged network access for host
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
NM_CONTROLLED=no

The crucial parts in this configuration is that eth0 is started on boot and is assigned a bridge device: ‘br0’. The ‘br0’ device is marked as a bridge device which completes the dependencies between them. So make sure if you deviate from the examples you leave the types and ‘bridge=br0’ in tact.

Categories
Linux / Gentoo Linux

KNetworkConf in KDE4 and Gentoo Baselayout-2

For a while now, I wondered why they ship KNetworkConf with KDE4 if its not working at all. The GUI shows up fine but none of the interfaces actually show up (making it pretty hard to configure them).

Today I found out why: the configuration panel is not incomplete, it is incompatible. You see, Gentoo is starting to switch to baselayout-2, a new and improved system layout which should solve a million quirks that have been part of the system for years now.

According to this bug report on kde.org, this is because the network listing is no longer the way it was: it is now a new kind of array (bash compatible or something).

Marvelous as this may be, it breaks knetworkconf in KDE 4.2.2 and older. Lets just hope that the new (service) release fixes this ‘ minor’ glitch.

Categories
How-To's

Network login script for Windows XP Home

I just needed a script to log in on a Windows 2003 Server from Windows XP Home. Of course you can enter your password each time you need to access the shares – or you could just drop this little script in your Startup folder (call it ‘network_login.vbs’ for example).

network_login.vbs:

{codecitation class="brush:vb"}’ VBScript to map a network drive. And provide a message box
‘ Author Berend Dekens http://www.cyberwizzard.nl/
‘ Based on code from Guy Thomas http://computerperformance.co.uk/
‘ —————————————————————–

Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath, bSaveMapping, strUserName, strPassword
strDriveLetter = "Z:"
strRemotePath = "\\192.168.100.1\sharename"
bSaveMapping = true
strUserName = "yourname"
strPassword = "mysecretpassword"
‘ Purpose of the script to create a network object. (objNetwork)
‘ Then to apply the MapNetworkDrive method. Result Z: drive
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, bSaveMapping, strUsername, strPassword
‘ Extra code just to add a message box
WScript.Echo "The networkdrive "& strDriveLetter & " is now available"
WScript.Quit
‘ End of MapNetworkDrive Example Logon Script. {/codecitation}