Fixed IPs within KVM on same subnet

Issues related to configuring your network
Post Reply
oldwizard
Posts: 12
Joined: 2011/06/24 15:26:20
Contact:

Fixed IPs within KVM on same subnet

Post by oldwizard » 2014/08/02 18:56:17

KVM out of the box works in that I can get traffic out of the KVM and log into things.

But I've been told to create a different experience. And I don't consider their request to be unreasonable.

The network is 192.168.11/24 and the CentOS host is 192.168.11.30

They want the virtual machines to be 192.168.11.31/24, 192.168.11.32/24 and 192.168.11.33/24

That way any other IP on the /24 can just ssh into 192.168.11.3[1-3].

When I look at the documentation https://access.redhat.com/documentation ... rking.html I'm not seeing a way to get to where I've been told to be.

I've tried things like:
ifconfig enp2s0:1 192.168.11.31
brctl addbr virbr0
brctl addif virbr0 enp2p0:1
(result the networking seems to go POOF!)
or changing the XML file /etc/libvirt/qemu/networks/autostart/default.xml directly but alas, that did not work.

So now I'm asking people with better virtualization chops than I for a map to get to where I've been requested to go.

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Fixed IPs within KVM on same subnet

Post by jlehtone » 2014/08/02 22:38:43

You referred to (RHEL) 6 documentation, youe post to (CentOS) 7 Forum. There is documentation for (RHEL) 7 too.

The virbr0 "virtual network" is by default a routed network. You apparently need a bridged network.

You do not assign addresses for the guests on the host. In a bridged network there are two possiblities:
1. The DHCP of the external physical network configures the guests as they boot up.
2. The guests set static address for themselves.

oldwizard
Posts: 12
Joined: 2011/06/24 15:26:20
Contact:

Re: Fixed IPs within KVM on same subnet

Post by oldwizard » 2014/08/03 00:01:03

jlehtone wrote:You referred to (RHEL) 6 documentation, youe post to (CentOS) 7 Forum.
And?

If I cite page #2 https://access.redhat.com/documentation ... bvirt.html somehow enlightenment will happen?

And what happens when one installs an old 3com 3c595 just to get a separate physical IP to follow those directions from 10.4/10.5 and it still doesn't work?

I cited the 6.0 documentation as that method looks similar to what had been cited as working on other GNU/Linux OSes.
jlehtone wrote:There is documentation for (RHEL) 7 too.
And that is a whopping 2 pages that tells you to set up a bridge and calls the configuration advanced and page 2 says go back one page. And the 1st thing page #1 says is go to page #2 where the commands listed sure seem to give a failure message.
jlehtone wrote: You apparently need a bridged network.
Fine - how to I get to where I have been told to go via this bridge idea?
jlehtone wrote:You do not assign addresses for the guests on the host.
I've added a whole new card to follow "the documentation" and even set the IP only on the guest per your post. But as one can see the 'enable network' part of the RTFM answer provided isn't quite working.
jlehtone wrote: In a bridged network there are two possiblities: 2. The guests set static address for themselves.
I deleted your #1 because it does not apply. ifconfig eth1 192.168.11.31 on the guest does not get out of the virtual machine.

If your next line is about how 10.5 says "NetworkManager does not support bridging. NetworkManager must be disabled to use networking with the network scripts" the result of following THAT advice looks like this:

Code: Select all

systemctl disable NetworkManager
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'
[root@apps ~]# systemctl enable network
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network on
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
What I'm asking for works on FreeBSD bhyve. It works on Oracle VirtualBox when running on CentOS 6.5 and doesn't need a separate physical card like the CentOS 7.0 documentation leads me to believe I need. I've been told to get it working with the built in KVM on CentOS 7. And that is why I'm asking the question - to get it working and not get 'RTFM' and 'I think it works this way' because it seems to me what I'm asking for should be able to happen.

Is CentOS 7 with systemd not up to the task I'm being asked for it to do?

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Fixed IPs within KVM on same subnet

Post by jlehtone » 2014/08/03 09:55:45

All I know about 7 is that it is not identical to 6. Therefore, the logical conclusion is that the manual of 7 should describe the 7 better than the manual of 6.

There are two separate issues:
1. What has to be done to achieve single subnet.
2. How to do it in 7.

The "virbr0" aka "Default network" of libvirt (in 6) represents a subnet and it is created by libvirt. The host has a virtual interface (and IP) on that subnet. Libvirt runs dnsmasq in order to provide DHCP and DNS for the guests that are connected to this subnet.

The host has three options for this subnet:
1. Do not route between virbr0 and physical subnet.
2. Route.
3. Route and NAT.
The libvirt management tools let you configure the choice. The virbr0 subnet has obviously different IP range than the physical subnet.

Bridging is different. The bridge is just one more switch on the physical subnet. The host has only one (public) IP. The IP is assigned to the bridge. The host does not have IP on its physical interface; that interface is enslaved to the bridge.

The "Default network" is not used at all for bridging; it should be shut down and prevented from starting at boot.

On 6 I do have interface 'br0' configured and 'eth0' modified. These are totally without and outside of libvirt configuration. Libvirt configures a guest to have interface on the 'br0'. Guest sets IP for its 'eth0'.

Other threads on this Forum have mentioned NM and 'network', so there must already be others who have wrestled with this on 7.

bertan
Posts: 55
Joined: 2014/01/12 23:43:19
Location: Canada

Re: Fixed IPs within KVM on same subnet

Post by bertan » 2014/08/03 11:03:07

If you want to do bridged networking on CentOS 7, with the default NetworkManager, then yes, it does work. I set up a Windows guest in such a way that it got a physical IP address on the LAN, accessible even from the outside world (via RDP and port-forwarding).
Last edited by bertan on 2014/08/03 19:13:43, edited 1 time in total.

oldwizard
Posts: 12
Joined: 2011/06/24 15:26:20
Contact:

Re: Fixed IPs within KVM on same subnet

Post by oldwizard » 2014/08/03 14:29:14

jlehtone wrote:All I know about 7 is that it is not identical to 6.
In the case of this issue, I was able to figure that out early on. Hopefully a SME will step forward with an answer.
jlehtone wrote:, so there must already be others who have wrestled with this on 7.
And perhaps some of those people will step forward.

Post Reply