How to make Windows guest running on qemu/kvm obtain IP address from physical router with DHCP server?

6,927

There is a native bridge (virbr0) that is installed with the QEMU/KVM environment. It is used for NAT (Network Address Translation) connections to your local subnet.

This should be sufficient for managing your IP camera. Your XP VM would only need its own IP on the net if other systems will be contacting it.

But in either case you should start with the NAT bridge to keep things simple until you are certain your XP VM is configured correctly. It almost certainly is not!

You can test for the presence of the Virtual Bridge on your host system by:

virsh net-dumpxml default

If it is present, you should be able to select it for use by your XP VM in virt-manager by setting Network source to "Virtual Network 'default':NAT" as shown:

virt-manager network selection

Check your XP for a working network driver. If the following picture is familiar... enter image description here

you need a driver disk! I recommend Red Hat's virtio driver.

  1. Download the latest virtio drivers ISO (https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.185-2/virtio-win.iso last I checked).
  2. Attach the ISO to your XP VM and boot it!
  3. At "Find new hardware"/connect to Window Update, decline (NO).
  4. Select "Install from specific location"/Next
  5. Select "Search removable media"/Next
  6. At Hardware Installation/Red Hat Virtio Ethernet Adapter", Select "Continue Anyway".
  7. Open a command prompt window and ping your IP camera (it may take a few seconds for the adapter to come up).

Add a comment if you still want the full bridge. I use networkd/Netplan exclusively in my environment but I could pound out a Network-Manager solution, I think.

Share:
6,927
Marecky
Author by

Marecky

I am in web development preschool ;)

Updated on September 18, 2022

Comments

  • Marecky
    Marecky over 1 year

    I am running Windows XP as a guest on Ubuntu 18.04 LTS with qemu/kvm.
    I want to use this Windows instance to manage my CCTV IP camera which uses ActiveX applets.

    I need this Windows XP to get IP from the same subnetwork as IP camera is.
    How can I configure this Virtual Machine using Virtual Machine Manager?

    I use a laptop, so my main connection is WiFi (inteface name wlp2s0).

    In the /etc/netplan/01-network-manager-all.yaml I have

    # Let NetworkManager manage all devices on this system
    network:
      version: 2
      renderer: NetworkManager
    

    And if I edit the content of my /etc/network/interfaces I get no connection to the internet (laptop does not bring up the WiFi connection)

    I tried this tutorial without any success

    Then I tried this one. Here is said "Then add the Ethernet interface as a port in the bridge..." and I noticed that nmcli command can be passed type argument. I read help about that argument and I managed to pass wifi ssid MYSSID arguments to configure that bridge with my WiFi connection.

    So I managed to pull these commands:

    sudo nmcli conn add type bridge con-name br0 ifname br0
    sudo nmcli conn add type wifi ssid MYSSID slave-type bridge con-name bridge-br0 ifname enp1s0 master br0
    

    In the second one I changed ethernet to wifi ssid

    sudo nmcli conn show --active
    sudo nmcli conn up br0
    

    Then the tutorial says I need to put down the ethernet connection - so I thought that in my case I need to put down wifi connection.

    How come this should work? I want my laptop to have a connection and my bridged virtual guest operating system to have one.

    When I issue ip a the br0 connection does not have an IP address from DHCP.

    If I bring up WiFi connection no new IP address shows up on the bridge interface (ip a)

    • Marecky
      Marecky over 3 years
      The things I did from the Chritopher answer didn't help me. It is laconic and does not cover my case (laptop with WiFi connection)
    • alfred
      alfred over 3 years
      Check link, you have to use ipvlan because your parent interface is a wireless adapter, specifically, use ipvlan L2 mode, if you don't want to change physical network's route. I don't think you can let DHCP work for such VM, you can try static IP setting. If you have a wired connection, you can use macvlan and DHCP.
    • Marecky
      Marecky over 3 years
      Sorry for not redistributing bounty points, I have no time right now to try one of new solutions to my question. Are the points gone forever, or can I grant them to chosen solution at any time?
  • Marecky
    Marecky almost 4 years
    Thanks, for your answer. I am trying to implement this solution but I have to take it in parts (a lot of reading, and things you just copied from documentations aren't working strait forward)
  • Marecky
    Marecky almost 4 years
    When I edit /etc/network/interfaces it gets cleared after reboot. I think it is caused by Network Manager
  • Marecky
    Marecky almost 4 years
    And my laptop gets its internet connection from wlp3s0: interface - should I exchange eth0 name with wlp3s0 in examples above?
  • Christopher H
    Christopher H almost 4 years
    To disable NetworkManager, run: sudo apt-get purge network-manager
  • Marecky
    Marecky almost 4 years
    Why I have to disable it?
  • Marecky
    Marecky almost 4 years
    And your command does not disable it, it just uninstall it. How I should manage my connection after that?
  • Thomas Ward
    Thomas Ward over 3 years
    @Marecky you either use netplan configurations or Network Manager to manage the configurations and bridges. Network Manager supersedes netplan so you have to use one or the other. You also should not use the /etc/network/faces method and only use Netplan to configure your bridges. This said, you can create bridges with Network Manager via nm-connection-editor - the old school advanced way of editing/maintaining Network Manager configs via the GUI.
  • Thomas Ward
    Thomas Ward over 3 years
    Note however if you're on wifi, you may want to consider not bridging and using NAT, because bridging to a wifi connection can sometimes not work right with giving IP addresses.
  • Marecky
    Marecky over 3 years
    I need full bridge solution because my CCTV camera's default configuration has disabled DHCP. It has static IP address which is from the other subnet (or group, I don't know how to name it). I want to be able to specify IP address of Windows XP Guest from the Internet Wi-Fi router. I have a Microtik device with plenty of configuration options and I can manage everything related to DHCP server and IP leases.
  • Marecky
    Marecky over 3 years
    First I will try the @raj solution. Just wait
  • Marecky
    Marecky over 3 years
    Thank you. After many weeks, I went back to setting up my IP camera. Indeed, it is exactly as you wrote, "This should be sufficient for managing your IP camera." Although my laptop (host) has an IP from the 192.168.88.200 subnet, the guest Windows XP can connect to the camera on the 192.168.1.168 subnet. I don't know why it didn't work for me then. While the topic of getting IP for a guest running QEMU / KVM still interests me, I can leave it for another day.
  • Frobozz
    Frobozz about 3 years
    I would be interested in your solution, @Marecky. I use bridges to copper in QEMU/KVM extensively but never successfully to a WiFi adapter - there is something "extra" going on there....