4

I have a really annoying issue. I am using KVM on CentOS 7 and two networks.

  • One of the networks is isolated with internal host routing only
  • The other network is forwarding using NAT.

I have set up two VM's. One of the VM's is only connected to the isolated network and the other is connected to both.

VM #1 - Gateway (nat network and isolated network) VM #2 - Isolated host (isolated network)

Now, the issue. I cannot get it VM #2 to be configured to use VM #1 as gateway with the network configuration. Sample below

<network>
  <name>isolated</name>
  <uuid>bbdafbfd-a73e-4a54-bc4d-2f060b571b71</uuid>
  <bridge name='virbr2' stp='on' delay='0'/>
  <mac address='52:54:00:46:53:61'/>
  <domain name='systems'/>
  <ip address='192.168.100.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.100.128' end='192.168.100.254'/>
    </dhcp>
  </ip>
</network>

Do I have to manually configure that each time the VM boot if I want to use DHCP? I can solve it by setting static configuration but I don't really want to use that.

Cheers

6
  • If you want VM#2 to use DHCP you need to configure the VM accordingly. But you haven't shown VM#2's network configuration. There's not much hope of anyone helping you as your question currently stands. Commented Nov 21, 2015 at 14:32
  • Well, the problem lies in the network configuration for the isolated network. I want to be able to set the default gateway in the configuration above, and I cannot find how to do it. VM #2 is a standard Win 7 with DHCP enabled. It relies on what is configure din the network, as mentioned above. If I set it to be static it works fine. VM #1 has IP 192.168.100.250 Commented Nov 21, 2015 at 16:03
  • Ah! I understand your problem now. The default gateway (and DNS) is the IP address of the interface above (192.168.100.1). I assume then, that your DHCP clients are either not being told this or choosing to ignore it. Have you used tcpdump or wireshark to see if it the gateway address is actually being sent by the host? Commented Nov 21, 2015 at 17:51
  • The IP above is the IP of the interface that is assigned by the virtual host. I want an entry such as gateway=192.168.100.250 that I can put somewhere in the settings so that the default gateway will be that inside the VM. But yes, you are correct. The gateway is not being sent, I have confirmed it. Commented Nov 21, 2015 at 18:16
  • Going by this bug, libvirt starts an instance of dnsmasq for each network, which cannot be configured. The suggestion there is to not enable dhcp in the XML file (as you've done) and then start your own version of dnsmasq with your own custom configuration. Commented Nov 21, 2015 at 22:35

1 Answer 1

1

As long as in your situation VM#1 is a gateway, it is intended to act as a DHCP server. So you just need to disable DHCP at network configuration xml (just remove anything between <dhcp> and </dhcp>) and run DHCP server or relay at VM#1.

I've just tested this approach and it works just fine for me.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.