:: Re: [DNG] Just out of curiosity, I …
Top Pagina
Delete this message
Reply to this message
Auteur: Adam Borowski
Datum:  
Aan: dng
Onderwerp: Re: [DNG] Just out of curiosity, I wondered,
On Wed, Aug 09, 2017 at 01:13:55AM +0200, Stefan Krusche wrote:
> Am Dienstag 08 August 2017 schrieb zap:
> > how do you enable internet in a virtual machine with qemu?
> >
> > I wanted to try to see how effectively certain distros such as gnuinos
> > and vuu-do work through qemu with upgrading actually working...
>
> I start VMs with qemu with the option "-net nic ", which provides a network
> device of/to the VM and have internet access without further configuring
> anything. See also qemu man page / documentation.


Note that this, user-mode networking, has its downsides, like ping not
working, troubles with listening (requires explicit config, no privileged
ports, etc). The official documentation recommends vlans, which take some
effort.

My personal favourite is bridged mode, which has only an one-time setup
cost, and makes guest VMs operate exactly same as if they were physically
separate machines plugged into your ethernet switch next to the host.
As a bonus, that setup cost is shared with lxc, which is also happy in
such a bridged configuration.

Not sure if all of setup steps below are still needed, they were ~5 years
ago:

* make /usr/lib/qemu/qemu-bridge-helper setuid root
* put "allow br0" into /etc/qemu/bridge.conf
* move network configuration from eth0 (or ens12345deadbeef678) to br0:
/etc/network/interfaces:

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet6 static
        bridge_ports eth0
        address 2001:dead:beef::42
        netmask 64
        gateway 2001:dead:beef::1
iface br0 inet static
    address 10.0.0.42
    ... yadda yadda yadda


(or just dhcp, whatever you use -- just move everything you have on eth0 to
br0, make eth0 "manual")
* pass "-net bridge -net nic" to qemu


Meow!
--
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢰⠒⠀⣿⡁ James Damore is a hero. Even mild criticism of bigots these days
⢿⡄⠘⠷⠚⠋⠀ comes at great personal risk.
⠈⠳⣄⠀⠀⠀⠀