KVM - The Linux Kernel-Based Virtual Machine
News, Blogs and Resources on the Linux (KVM) Kernel-Based Virtual Machine

CentOS node - VPS unable to connect to internet

4 replies [Last post]
BThomas
User offline. Last seen 22 weeks 5 days ago. Offline
Joined: Feb 20 2010
Points: 7

Hi all,

I've spent the last two days reading guides, looking for information, etc. on how to do this, and as of yet have had no luck - so decided I would come here and try asking the experts :)

First things first...

I have a Core i7 server running CentOS 5.4, with a custom kernel that I built, KVM is built-in, as is support for network bridges - I can not change the OS on this, as it is being used in production for other things.

I have successfully setup a CentOS VM, and can access this via virt-manager, but have not been able to get it to connect to the internet.

This is the end result that I need:
Host Server IP (static) = 188.165.xxx.xxx
VPS Server IP (static) = 178.32.xx.xxx

I beleive this is a correct network diagram:

                   HOST            KVM GUEST
            +---------------+   +---------------+
INTERNET ---+-eth0          |   | 178.32.xx.xxx |
            | |  +-------+--+---+----- eth0     |
            | |  | vnet0 |  |   +---------------+
            | |  +-------+  |
            | |     |       |
            | +----br0      |
            |188.165.xxx.xxx|
            +---------------+

Internet <-> eth0 <-> br0 (188.165.xxx.xxx) <-> vnet0 <-> eth0 (178.32.xx.xxx)

Note: Any requests for the VPS IP (178.32.xx.xxx) are routed to the server IP (188.165.xxx.xxx), so I need to get the traffic sent both ways.

Right, now for what I have done:

1) Put the following in /etc/sysctl.conf

net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

2) iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT

3) created br0, which I attached to eth0 - br0 now has the static IP/gateway that were attached to eth0 originally - this bridge does work, and I can access the server via it.

ifconfig (when VPS is running): http://pastie.org/private/mcbs51dvhw3etnotbogbg
brctl show (when VPS is running): http://pastie.org/private/m1dgku7mslzybyjggtlaq

4) ip route add 178.32.xx.xxx dev br0 (on the host)
route -v (on host): http://pastie.org/private/1s7oktkvxj1gfjted9oqw

5) Start KVM VPS via virt-manager assign IP on VPS (ifconfig eth0 178.32.xx.xxx/32 up)

6) ip route add default dev eth0 (on the VPS)

After doing this, I am able to ping the host from the VPS, and vice-versa.
However, I am not able to ping the VPS from the outside world, and I am not able to connect to the internet from the VPS.

If someone could point out what I am missing out here, or if I am doing something wrong it really would be very much appreciated.
For example, is vnet0 supposed to have an IP?

Many Thanks!

Kenni Lund
User offline. Last seen 2 days 26 min ago. Offline
Joined: Nov 25 2008
Points: 78
Re: CentOS node - VPS unable to connect to internet

Have you enabled IP-forwarding in /etc/sysctl.conf on your host?
net.ipv4.ip_forward = 1

Best Regards
Kenni Lund

Kenni Lund
User offline. Last seen 2 days 26 min ago. Offline
Joined: Nov 25 2008
Points: 78
Re: CentOS node - VPS unable to connect to internet

> For example, is vnet0 supposed to have an IP?

No, it's not.

Best Regards
Kenni Lund

BThomas
User offline. Last seen 22 weeks 5 days ago. Offline
Joined: Feb 20 2010
Points: 7
Hi Kenni, Thanks for the

Hi Kenni,

Thanks for the replies - yes net.ipv4.ip_forward = 1 is set in my /etc/sysctl.conf
This is what I currently have in it: http://pastie.org/private/ufilryfuimhp3smqgeeng

Something else I noticed just now was this:

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

Do either of those need to be enabled/disabled?

Many Thanks,
Ben Thomas

BThomas
User offline. Last seen 22 weeks 5 days ago. Offline
Joined: Feb 20 2010
Points: 7
Turned out it was an issue

Turned out it was an issue with my server provider.

The MAC address of the VM was not recognized, so it was not allowing it to connect to the network, after getting the vMAC added to their routers this issue was resolved.

Post new comment

The content of this field is kept private and will not be shown publicly.