0

We're running a CentOS 7 server, with KVM installed on top of it, and the host has 2 Ethernet interfaces attached to it (em1 and em2).

A new windows 7 VM was just created, and we wanted that specific machine to be connected to the office network (192.168.2.X), so we went with the bridge solution by creating a 'br0' interface, and bridging it with the physical interface 'em2'.

So even when assigning a static IP to the guest W7 VM through 'br0', it's not taking that particular IP, but a whole other one, plus from the guest side we were able to see other machines/devices on the same subnet, but it doesn't work the other way (physical machines can't ping VM), using the specified IP of 'br0' or the other IP.

so we are we missing ?

So here is a copy of the configuration files:

ifconfig em2

em2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 54:9f:35:02:b2:5a  txqueuelen 1000  (Ethernet)
        RX packets 4296203  bytes 5223242102 (4.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 655608  bytes 711971529 (678.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17

ifconfig br0

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.34  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::569f:35ff:fe02:b25a  prefixlen 64  scopeid 0x20<link>
        ether 54:9f:35:02:b2:5a  txqueuelen 0  (Ethernet)
        RX packets 562034  bytes 36288591 (34.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 307114  bytes 1132593995 (1.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

/etc/sysconfig/network-scripts/ifcfg-em2

DEVICE=em2
NAME=em2
TYPE=Ethernet
HWADDR=54:9F:35:02:B2:5A
BOOTPROTO=none
ONBOOT=yes
BRIDGE=br0

/etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
NAME=br0
TYPE=Bridge
IPADDR=192.168.2.34
PREFIX=24
BOOTPROTO=none
ONBOOT=yes
DELAY=0

/etc/sysconfig/network

NETWORKING=yes
GATEWAY=192.168.2.1

ipconfig (guest machine)

IPv4 Address: 192.168.2.159
subnet mask: 255.255.255.0
Default Gateway: 192.168.2.1

brctl show br0

bridge name bridge id       STP enabled interfaces
br0     8000.549f3502b25a   no      em2
                            vnet0
2
  • did that already, still no IP, but when I tried to set the IP for 'em2', it was changed on 'br0' side, but not on the guest machine side.
    – Raafat
    Aug 4, 2015 at 6:48
  • My suggestions got too long for a comment, so I deleted it and turned it into an answer. Try the second part of that!
    – MadHatter
    Aug 4, 2015 at 6:50

2 Answers 2

0

You don't seem to have an ipv4 address on br0. That will prevent your CentOS host from talking to the VM guest.

I accept that your ifcfg-br0 is set up for it, but it hasn't taken, and in any case I can see odd things in it (BOOTPROTO=none?). Try ifdown br0; ifup br0 and see if that helps.

If not, just enforce the address on the interface with ifconfig br0 192.168.2.34 netmask 255.255.255.0 up and see if that fixes things from a network standpoint, then we can discuss how to fix the config files.

Do not set an ip address on em2. It would also be useful if you edited into your question the output of brctl show br0.

Edit: OK, good, we've got your ipv4 working, now we just need to fix your config files. Try this in ifcfg-br0:

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.2.34
NETMASK=255.255.255.0
ONBOOT=yes

Then bounce the interface with ifdown br0; ifup br0, and if that works, try a reboot.

11
  • the 2nd part worked (forcing the IP into the interface), but the VM windows guest still has the other IP (159), plus if I need to restart the network service on the host machine 'systemctl restart network', the 'br0' will lose the forced IP
    – Raafat
    Aug 4, 2015 at 7:03
  • Yes, the Windows guest is supposed to have a different IP. The question is, can you ping/talk to it once you force the address on the br0 interface?
    – MadHatter
    Aug 4, 2015 at 7:09
  • Well, yes actually I can
    – Raafat
    Aug 4, 2015 at 7:13
  • Good, good; see edit 1 above.
    – MadHatter
    Aug 4, 2015 at 7:15
  • Unfortunately it's still losing the IP when taking the interface down and up again, I had to set it manually.
    – Raafat
    Aug 4, 2015 at 7:25
0

The IP address on br0 is not the IP address of the guest. It is the address of your host machine. With this setup, you can imagine as if you had a separate physical machine with Windows 7 connected to the switch through cable comming out of em2.

If you want static IP on your guest, you need to set it up on your guest. Or update a DHCP server to assign static IP. (btw. careful, if you set things up through libvirt, it may start dnsmasq DHCP server on the bridge interface, which would cause it to do parasitic DHCP on your office network).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .