Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've already setup a KVM host with proper IP configurations, but my host had me create DHCP and use that to assign the IP's to the machines. I want to see if there's an easier way to do it (or better). Upon my first setting out on this, I didn't find anything that pointed me in the right direction. I'm coming off a fresh install of Debian 6.0 x64, so I have nothing installed. I've logged in, queried for the below information and changed the password from my host set one.

I have a Debian 6.0 x64 system with the following initial network configuration (substituted 255 in place of my real first octave):

# tail /etc/network/interfaces
auto  eth0
iface eth0 inet static
address   255.9.24.80
broadcast 255.9.24.95
netmask   255.255.255.224
gateway   255.9.24.65

# default route to access subnet
up route add -net 255.9.24.64 netmask 255.255.255.224 gw 255.9.24.65 eth0

I have a /29 subnet that I want the virtual machines to use from my host:

IP: 255.46.187.152 /29
Mask: 255.255.255.248
Broadcast: 255.46.187.159

Usable IP addresses: 255.46.187.153 to 255.46.187.158

I like the interface of Cloudmin, so I want to try and use that if I can to administrate my guests.

So, my questions:

How do I set this up on the host system the best so that I can use the additional Subnet IP's on the guests and have them accessible from the internet?

I also need to host a DNS server, which means one of these VM's has to have two IP's assigned to it and accessable from the outside world. How can I do that using Cloudmin? I had a question about this here: Multiple IP addresses assigned to one KVM VM But I just reformatted the entire server and am trying to figure out a better way of doing this.

Machine information:

# ip route show
255.9.24.64/27 via 255.9.24.65 dev eth0
255.9.24.64/27 dev eth0  proto kernel  scope link  src 255.9.24.80
default via 255.9.24.65 dev eth0

brctl is empty

# ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
  valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether c8:60:00:54:b5:d8 brd ff:ff:ff:ff:ff:ff
inet 255.9.24.80/27 brd 255.9.24.95 scope global eth0
inet6 fe80::ca60:ff:fe54:b5d8/64 scope link
  valid_lft forever preferred_lft forever

Thank you for any help you can provide me.

EDIT: I've installed kvm and cloudmin:

aptitude install qemu-kvm libvirt-bin
wget http://cloudmin.virtualmin.com/gpl/scripts/cloudmin-kvm-debian-install.sh
./cloudmin-kvm-debian-install.sh

Rebooted and now my network configuration looks like this:

# device: eth0
iface eth0 inet manual

# default route to access subnet


iface br0 inet static
    address 255.9.24.80
    netmask 255.255.255.224
    broadcast 255.9.24.95
    network 255.9.24.64
    bridge_ports eth0
    gateway 255.9.24.65

I setup in Cloudmin the Start IP as 255.46.187.153 and End IP as 255.46.187.158. The CIDR is 29 and the gateway is 255.46.187.152.

I've installed a guest with ubuntuserver 12.04 x64, which was able to get and retrieve internet resources during installation, but now cannot reach anything nor can it be reached from anything. Its network configuration is:

iface eth0 inet static
 address 255.46.187.153
 netmask 255.255.255.224
 broadcast 255.46.187.159
 gateway 255.46.187.152
 dns-nameservers <host provided nameservers>

And is not able to ping google.com through DNS or direct IP, I can't ping the VM from the outside or the host. any ideas now?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

The gateway configured on guest is not an IP of the host machine, I would try this config on guest:

auto eth0
iface eth0 inet static
       address 255.46.187.153
       netmask 255.255.255.255
       gateway 255.9.24.80
       pointopoint 255.9.24.80
       dns-nameservers <host provided nameservers>
       up ip addr add 255.46.187.154 dev eth0

also on host, make sure to add the route to to guest, add this to /etc/network/interfaces

iface eth0 inet static
       (...)
       up route add -host 255.46.187.153 dev br0
       up route add -host 255.46.187.154 dev br0

this way you can use network and broadcast addresses for guests (255.46.187.152 and 255.46.187.159)

some resources, sorry not in english:

http://www.ingent.net/ca/2012/03/server-virtualization-kvm-hetzner/ (catalan)

http://wiki.hetzner.de/index.php/KVM_mit_Nutzung_aller_IPs_-_the_easy_way (german)

share|improve this answer
    
I remember trying this configuration (hetzner is actually my host) a while ago, and it did not work. I just re-tried it, paying attention to all configs and it still does not work. –  Jguy Aug 26 '12 at 0:02
    
I originally followed this guide: wiki.hetzner.de/index.php/KVM_mit_Nutzung_aller_IPs_aus_Subnetz and it worked. The only limitation is the fact that I need to assign up to 4 IP's (I think godaddy requires 4) to register my own nameserver. I cant seem to do that with that configuration. –  Jguy Aug 26 '12 at 0:07
    
I am at hetzner too, and I followed the two guides, both are working but first is simpler (the easy way one) –  tictacbum Aug 26 '12 at 9:14
    
I edited answer to configure additional IP on guest –  tictacbum Aug 26 '12 at 9:27
1  
@JohnMish As an aside, your domain's nameservers should not be on the same host, or even in the same data center. That defeats the whole purpose of redundancy and high availability. –  Michael Hampton Aug 26 '12 at 9:46
show 2 more comments

If the VM aren't on the same network as the host, then you may need to set up the host as a router for the VMs:

iptables --table nat --append POSTROUTING --out-interface br0 -j MASQUERADE
iptables --append FORWARD --in-interface br0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward

Edit: Sorry for the "MASQUERADE", I simply copy-pasted a script I had lying around. In your case, you don't need it. But it can be useful in a different case, for instance when you want to give your VMs privates IPs.

share|improve this answer
    
What's the MASQUERADE business for? He doesn't seem to be using NAT. –  Michael Hampton Aug 25 '12 at 20:51
    
Indeed. No NAT here. –  Jguy Aug 26 '12 at 0:01
1  
Blah. Can't +1 your answer. I had forgot the ip_forwarding. Thanks for pointing it out! –  Jguy Aug 27 '12 at 2:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.