Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: how can I get the same range of the network for VM as the host?

  1. #1

    Default how can I get the same range of the network for VM as the host?

    Hi All,

    I am using a Quemu/KVM and my VM gets network x.x.10.180 but I want to have this machine in the same range as the host x.x.7.71 is there any way doing it?

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,853

    Default Re: how can I get the same range of the network for VM as the host?

    Sorry, but networks are defined by the FIRST number of bits (often 24 of them) of the address. You only show last numbers. The first few bits of what you post may be part of the network, but the rest up to the end is the host address.
    Thus your information is of not much use to explain what you have.

    Netwrorks are written down as e.g. 10.0.0.0/24, which means that the first 10.0.0 is the network and the remaining 8 bits are available for hosts (minus 0 and 255).
    Henk van Velden

  3. #3

    Default Re: how can I get the same range of the network for VM as the host?

    hi I am sorry I thought this is obvious. Lets say:

    I am using a Quemu/KVM and my VM gets network 192.168.122.68 but I want to have this machine in the same range as the host 192.168.2.158 is there any way doing it?

    but the problem is different. I have changed the network manually on the VM to match the host range 192.168.2.160 and almost ok but the host and VM cant see to each other.

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,853

    Default Re: how can I get the same range of the network for VM as the host?

    I think you should have added what one (or both) networks are, by either showing the netwmask, or by doing it as I did above.
    IMHO there are two possibilities now:
    • the netmask is 255.255.255.0, which would make both networks 192.168.122.0/24 and 192.122.2/24;
    • or the netmask is 255.255.0.0, which would make only one network 192.168.0.0/16.

    And even many more possibilities of subnetting.

    But I assume the first one above is what you mean because else both systems would already belong to the same network.
    Henk van Velden

  5. #5
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,644
    Blog Entries
    14

    Default Re: how can I get the same range of the network for VM as the host?

    You need to setup the networking of KVM/Qemu differently. You now have a NAT bridge ( I can see that from the defaults ), where you want the VM to use the physical network. I've never used that, so have no experience in setting such up, but I know f.e. virt-manager shows these options.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  6. #6

    Default Re: how can I get the same range of the network for VM as the host?

    Just putting my 2 cents based on my experience.

    If I may ask, what do you need to achieve by putting VM guest and host in the same subnet?

    If you just want bidirectional host <-> guest(s) -in case you have more VM guests in the host- communication, the (default) NAT virtual network is just enough.
    Just one detail with Windows VMs: guest -> host communication works, but firewall service blocks host -> guest communication out of the box. In my case I had to disable the service and reboot Windows VM; I'm not sure if it's possible to somewhat add rules/exceptions to Windows firewall...

    With NAT network you can also ping devices within host's physical LAN from VM guest, but they cannot ping the VM; this is how NAT works. As a note, you may have noticed that virtual network wizard doesn't allow to set subnet the same as host's subnet, giving error instead.
    If you also need LAN devices to see the VM guest(s) inside your host, most direct way -in summary; I haven't done it myself yet- is creating a network bridge in your host and use it for both your VM guests (the bridge will be visible when configuring network in the create VM wizard), and also your ethernet device itself.
    This network bridge method effectively puts both VM guest(s) and physical LAN in the same subnet.

    To create a bridge with Network Manager one can either use nmcli command line, or nm-connection-editor for GUI (installing NetworkManager-connection-editor package). I think there are several tutorials around internet regarding both.
    One can also create bridges using Yast; in fact Yast offers to create one when first installing the virtualization stuff via Yast's virtualization module. But Yast's bridges seem to be only usable for Wicked, not Network Manager.

    It's been said here in the forums that wireless network devices cannot be added to a bridge, however Arch Linux and Debian wikis say it's possible, though more convoluted. Probably just less practical...

    Finally, aside NAT network, there's also the "routed" option in libvirt's virtual networks. But as far as I read, it's a more advanced, commonly less used configuration. Kind of aimed to making "secured network zones", and involves adding correct routes to individual LAN devices and/or LAN router to achieve communication with the VMs.

  7. #7
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,346
    Blog Entries
    3

    Default Re: how can I get the same range of the network for VM as the host?

    I'll agree with Knurpht.

    Here, my VMs are on the same network as the host. But that's because I set them up to use a bridge instead of using NAT. So they get their IP from the general network router.

    I don't actually need this, and the next time that I install virtualization tools, I'll probably set it to use NAT. But, when using NAT, it will need to use a different subnet for the VMs to avoid a conflict.
    openSUSE Leap 15.1; KDE Plasma 5;

  8. #8
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,917
    Blog Entries
    2

    Default Re: how can I get the same range of the network for VM as the host?

    If you installed KVM using the YaST virtualization module,
    You would already have a bridge called br0, you would then simply re-configure your Guest's Networking properties (using vm manager most likely). That puts your Guest on the same physical network as your HostOS and every other machine in your LAN. If your LAN has a DHCP server, you can configure your Guest to be a DHCP client for easy network configuration, otherwise you'd have to configure a static address, default gateway and DNS manually.

    If you didn't install KVM using the YaST module, you can create a "bridging" bridge device using vm manager (create a virtual network), YaST or command line using the "brctl" utility, or even nmcli or Network Manager (these I don't necessarily recommend). IIRC all these methods should set up a "bridging" bridge device if you simply accept all defaults (I haven't checked all in a very long time, though).

    Otherwise, if you haven't done anything special (Assuming as a beginner you didn't go wildly off track on what you're allowed to do by default), you might be able to simply run the YaST virtualization module even after manual installation of KVM and perhaps libvirt to be properly installed with no missing parts and with a standardized configuration.

    Although not applicable to initial installation, I recommend the SLES 11 SP4 virtualization documentation for configuration topics like this Forum post/thread, although ti's getting very old the info is still the most accurate published by SUSE/openSUSE

    https://www.suse.com/documentation/opensuse114/

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  9. #9
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    10,917
    Blog Entries
    2

    Default Re: how can I get the same range of the network for VM as the host?

    Additionally,

    My previous post only addresses how to set up your Guest so that it's on the same Network as your HostOS and LAN.
    For the very special situation communicating between Guest and HostOS, although you will find that although you should be able to communicate by IP address, typically you will still not be able to communicate by name... And this is because ordinarily there is no common name authority shared between Guest and HostOS (this is true of all virtualization technologies, not just KVM). The name servies provided in a NAT bridge device environment will be unaware of the HostOS names although it will know the names of each Guest using the same bridge device.

    The simple solution of you want name resolution between Guest and HostOS is to recognize the issue, and address it... Probably the most common and simplest is to point the Guest and Host to an "external" DNS, eg if one exists on your LAN, but would still have to look at how DNS entries are populated. Or, the alternative is to create appropriate host file entries on each machine.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  10. #10
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    20,173
    Blog Entries
    1

    Default Re: how can I get the same range of the network for VM as the host?

    Quote Originally Posted by tsu2 View Post
    The simple solution of you want name resolution between Guest and HostOS is to recognize the issue, and address it... Probably the most common and simplest is to point the Guest and Host to an "external" DNS, eg if one exists on your LAN, but would still have to look at how DNS entries are populated. Or, the alternative is to create appropriate host file entries on each machine.

    TSU
    ...or consider using Avahi local hostname resolution perhaps. (That suits my needs just fine.)
    openSUSE Leap 15.0; KDE Plasma 5

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •