2

I'm trying to setup a Xen virtualization on Ubuntu 16.04, and Xen 4.6.

My plan is to have 1 private network, as well as virtual servers with public IP addresses which should be accessible externally (as well as connected to the private network). My hosting provider gives me 4 additional public IPs.

For this, I've setup two bridges:

# brctl show
bridge name     bridge id               STP enabled     interfaces
xenbr0          8000.0025907784d4       no              eth0
                                                        vif3.0
                                                        vif3.0-emu
xenbr1          8000.36829b44377f       no              dummy0
                                                        vif3.1
                                                        vif3.1-emu

xenbr0 has the public static IP, and xenbr1 a private one (192.168.122.1)

I've then configured the virtual machine as follows

vif=[
 'ip=<virtual server public ip>,mac=02:00:00:c1:fb:49,bridge=xenbr0',
 'ip=192.168.122.6,mac=00:16:3E:59:FC:39,bridge=xenbr1'
 ]

I can connect to the 192.168.122.6 address just fine, and that machine has access to the internet correctly configured through the 192.168.122.1 gateway. So everything is good there.

I then add the public IP in /etc/network/interfaces on the virtual server

auto eth0
iface eth0 inet static
    address <public ip>
    netmask 255.255.255.255
    network <public ip substituting .0 at the end>
    broadcast <public ip>
    hwaddress ether 02:00:00:c1:fb:49

And the internal network (which has the gateway)

iface eth1 inet static
        address 192.168.122.6
        netmask 255.255.255.0
        network 192.168.122.0
        broadcast 192.168.122.255
        gateway 192.168.122.1

Now the route looks like this

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.122.1   0.0.0.0         UG    0      0        0 eth1
192.168.122.0   *               255.255.255.0   U     0      0        0 eth1

I can ping the IP from the server itself obviously - but I can't connect to it externally, or from the xen server itself.

What am I doing wrong?

  • Thank you for the reply - I've added the details of the 2nd internal network above, which has the default gateway. I've tried the 255.255.255.0 netmask as you suggest, but I only have a single IP on this range assigned to the server / interface, so I think 255.255.255.255 is correct. I still can't access that VM remotely by its public IP – Kevin Blake Jun 12 '16 at 9:25
  • The .255 was provided by my hosting provider. I also have eth1 configured (with a 255.255.255.0) netmask where my outbound routing is configured (that's where the .1 and .6 local addresses are). eth0 doesn't belong to the 192.168.0.0 network. – Kevin Blake Jun 13 '16 at 6:39
  • Ah! My bad! I misread your question :-o I assumed the .255 was on the private side. – garethTheRed Jun 13 '16 at 6:46
  • 1
    The default line of your routing table doesn't look right. As it stands, everything is routed through the private network. The Gateway should be the ISP IP address and the Iface should be eth0 so that Internet traffic is routed via the ISP. (assuming I've read your question correctly) – garethTheRed Jun 13 '16 at 7:06
  • I think you're onto something there. To simplify things I went back to basics and removed the private network altogether. Then added static routes to the xen host, and the xen hosts gateway. route add x.x.x.94 dev eth0 \ route add x.x.x.254 dev eth0 \ route add default gateway x.x.x.254 Now everything seems to be working, and I can access either server remotely. Thank you for helping out - much appreciated! This has been driving me a little nuts :) – Kevin Blake Jun 13 '16 at 18:00
1

My mistake appears to be routing all of the traffic over the private network, and via eth1 - xenbr1 - dummy0. eth1 should be used for the private network only, and eth0 used for general traffic.

So from eth1 on the virtual machine, remove the gateway in /etc/network/interfaces:

iface eth1 inet static
        address 192.168.122.6
        netmask 255.255.255.0
        network 192.168.122.0
        broadcast 192.168.122.255

And change eth0 to include static routes to both the host machine, and host's gateway (I'm certain this can be done for the whole range, rather than the 2 IPs individually, to further simplify this).

iface eth0 inet static
    address 129.x.x.199
    netmask 255.255.255.0
    broadcast 129.x.x.199
    up route add 23.x.x.94 dev eth0
    up route add 23.x.x.254 dev eth0
    up route add default gw 23.x.x.94
    down route del default gw 23.x.x.254
    down route del 23.x.x.94 dev eth0
    down route del 23.x.x.254 dev eth0

Note I've also removed the gateway definition from this one - until the static routes are added, the gateway is inaccessible (which leaves the network unable to start).

Now all internet traffic is routed through the eth0-xenbr0-eth0 bridge, and private traffic routed through eth1-xenbr1-dummy0.

The final route table looks like this:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         23.x.x.254 0.0.0.0         UG    0      0        0 eth0
23.x.x.94 *               255.255.255.255 UH    0      0        0 eth0
23.x.x.254 *               255.255.255.255 UH    0      0        0 eth0
129.0.0.0   *               255.255.255.0   U     0      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 eth1

Thank you to garethTheRed for your assistance!

  • I ran into a similar issue where when I configure the xenbr1 the external ip become inaccessible. Your answer is showing me some hope. Can you clarify the component dummy0? What is it and why is it required? Thanks – jazaman Jul 19 '17 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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