Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #224487 > unrolled thread

systemd-nspawn networking inside VirtualBox VM

Started byDidar Hossain <didar@purlo.in>
First post2020-07-07 15:40 +0200
Last post2020-07-08 18:10 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.debian.user


Contents

  systemd-nspawn networking inside VirtualBox VM Didar Hossain <didar@purlo.in> - 2020-07-07 15:40 +0200
    Re: systemd-nspawn networking inside VirtualBox VM john doe <johndoe65534@mail.com> - 2020-07-07 18:30 +0200
      Re: systemd-nspawn networking inside VirtualBox VM Alexandre Rossi <niol@zincube.net> - 2020-07-08 07:40 +0200
        Re: systemd-nspawn networking inside VirtualBox VM Didar Hossain <didar@purlo.in> - 2020-07-08 18:40 +0200
      Re: systemd-nspawn networking inside VirtualBox VM Didar Hossain <didar@purlo.in> - 2020-07-08 18:10 +0200

#224487 — systemd-nspawn networking inside VirtualBox VM

FromDidar Hossain <didar@purlo.in>
Date2020-07-07 15:40 +0200
Subjectsystemd-nspawn networking inside VirtualBox VM
Message-ID<ApVZf-1HS-3@gated-at.bofh.it>
Hi,

TL;DR
How to get systemd-nspawn containers networking so that they can talk to each
other, the host and the internet inside a Buster VM? VirtualBox on Windows 10
which has internet connectivity via a wireless interface.



I am running a Buster VM with hand picked minimal packages, networking is
configured simply using interfaces(5) file with DHCP. I have configured a
"NatNetwork" on VirtualBox which allows the VMs to connect to each other and the
internet. I was wondering if I can do similar thing with containers inside the
buster VM.

I used `debbootstrap' to have a template directory of buster under
"/opt/templates/buster". I then simply copy the directory tree over to
"/var/lib/machines". I tried a few networking options of `systemd-nspawn', but
since I am not well educated about macvlan, ipvlan, I could not get the
networking working at all. I would like to avoid using
"systemd-networkd/systemd-resolvd" especially on the Buster host - using those
it seems should make everything work automagically.

If it works then I will be able to test my Dovecot/Exim setup easily in such
throwaway containers. I currently do testing using VMs.

Does anyone have experience in having this kind of scenario working?

Regards,
Didar

-- 
Baby On Board.

[toc] | [next] | [standalone]


#224511

Fromjohn doe <johndoe65534@mail.com>
Date2020-07-07 18:30 +0200
Message-ID<ApYDL-3mL-1@gated-at.bofh.it>
In reply to#224487
On 7/7/2020 3:13 PM, Didar Hossain wrote:
> Hi,
>
> TL;DR
> How to get systemd-nspawn containers networking so that they can talk to each
> other, the host and the internet inside a Buster VM? VirtualBox on Windows 10
> which has internet connectivity via a wireless interface.
>
>
>
> I am running a Buster VM with hand picked minimal packages, networking is
> configured simply using interfaces(5) file with DHCP. I have configured a
> "NatNetwork" on VirtualBox which allows the VMs to connect to each other and the
> internet. I was wondering if I can do similar thing with containers inside the
> buster VM.
>
> I used `debbootstrap' to have a template directory of buster under
> "/opt/templates/buster". I then simply copy the directory tree over to
> "/var/lib/machines". I tried a few networking options of `systemd-nspawn', but
> since I am not well educated about macvlan, ipvlan, I could not get the
> networking working at all. I would like to avoid using
> "systemd-networkd/systemd-resolvd" especially on the Buster host - using those
> it seems should make everything work automagically.
>
> If it works then I will be able to test my Dovecot/Exim setup easily in such
> throwaway containers. I currently do testing using VMs.
>
> Does anyone have experience in having this kind of scenario working?
>

For testing purposes, I use in a Buster VM systemd-container.
That is if your VM has internet access the containers will also get
internet access .

For sake of simplicity, I would strongly suggest you to use in the VM
systemd-networkd to get the networking working between the containers
and the VM.

$ debootstrap --include=systemd-container

You need the above debootstrap pkg for systemd-networkd to work in the
container.

Then in the VM and in eatch container, simply enable systemd-networkd.


If you realy want to do the networking yourself, you will need to create
the bridge based on the examples found in '/lib/systemd/network'.

--
John Doe

[toc] | [prev] | [next] | [standalone]


#224573

FromAlexandre Rossi <niol@zincube.net>
Date2020-07-08 07:40 +0200
Message-ID<AqaYi-2xz-5@gated-at.bofh.it>
In reply to#224511
Hi,

> > since I am not well educated about macvlan, ipvlan, I could not get the
> > networking working at all. I would like to avoid using
> > "systemd-networkd/systemd-resolvd" especially on the Buster host - using those
> > it seems should make everything work automagically.
> 
> If you realy want to do the networking yourself, you will need to create
> the bridge based on the examples found in '/lib/systemd/network'.

I've had success declaring a bridge in /etc/network/interfaces:

    iface br0 inet dhcp
        bridge_ports eth0 # this is your VM Ethernet

and launching my containers with:

    $ cat /etc/systemd/nspawn/container.nspawn
    [Exec]
    Boot=yes

    [Network]
    Bridge=br0
    $ sudo machinectl start container

Alex

[toc] | [prev] | [next] | [standalone]


#224607

FromDidar Hossain <didar@purlo.in>
Date2020-07-08 18:40 +0200
Message-ID<AqlgZ-dW-3@gated-at.bofh.it>
In reply to#224573
On Wed, Jul 08, 2020 at 07:20:18AM +0200, Alexandre Rossi wrote:
> Hi,
> 
> > > since I am not well educated about macvlan, ipvlan, I could not get the
> > > networking working at all. I would like to avoid using
> > > "systemd-networkd/systemd-resolvd" especially on the Buster host - using those
> > > it seems should make everything work automagically.
> > 
> > If you realy want to do the networking yourself, you will need to create
> > the bridge based on the examples found in '/lib/systemd/network'.
> 
> I've had success declaring a bridge in /etc/network/interfaces:
> 
>     iface br0 inet dhcp
>         bridge_ports eth0 # this is your VM Ethernet
> 
> and launching my containers with:
> 
>     $ cat /etc/systemd/nspawn/container.nspawn
>     [Exec]
>     Boot=yes
> 
>     [Network]
>     Bridge=br0
>     $ sudo machinectl start container

I tried this as well. Looks like some specific problem for my setup.


> 
> Alex
> 

I have decided not to pursue this anymore, I need to get things done so will put
this off till I have proper resources and time.

Thanks for all the help to everyone.

Kind regards,
Didar

-- 
Put your brain in gear before starting your mouth in motion.

[toc] | [prev] | [next] | [standalone]


#224606

FromDidar Hossain <didar@purlo.in>
Date2020-07-08 18:10 +0200
Message-ID<AqkNX-8wo-11@gated-at.bofh.it>
In reply to#224511
On Tue, Jul 07, 2020 at 06:05:14PM +0200, john doe wrote:
> On 7/7/2020 3:13 PM, Didar Hossain wrote:
> > Hi,
> > 
> > TL;DR
> > How to get systemd-nspawn containers networking so that they can talk to each
> > other, the host and the internet inside a Buster VM? VirtualBox on Windows 10
> > which has internet connectivity via a wireless interface.
> > 
> > 
> > 
> > I am running a Buster VM with hand picked minimal packages, networking is
> > configured simply using interfaces(5) file with DHCP. I have configured a
> > "NatNetwork" on VirtualBox which allows the VMs to connect to each other and the
> > internet. I was wondering if I can do similar thing with containers inside the
> > buster VM.
> > 
> > I used `debbootstrap' to have a template directory of buster under
> > "/opt/templates/buster". I then simply copy the directory tree over to
> > "/var/lib/machines". I tried a few networking options of `systemd-nspawn', but
> > since I am not well educated about macvlan, ipvlan, I could not get the
> > networking working at all. I would like to avoid using
> > "systemd-networkd/systemd-resolvd" especially on the Buster host - using those
> > it seems should make everything work automagically.
> > 
> > If it works then I will be able to test my Dovecot/Exim setup easily in such
> > throwaway containers. I currently do testing using VMs.
> > 
> > Does anyone have experience in having this kind of scenario working?
> > 
> 
> For testing purposes, I use in a Buster VM systemd-container.
> That is if your VM has internet access the containers will also get
> internet access .
> 
> For sake of simplicity, I would strongly suggest you to use in the VM
> systemd-networkd to get the networking working between the containers
> and the VM.

I finally gave in and tried things with systemd-networkd - it worked. It seems
the trick is mostly the way routing is setup, "ip route" shows multiple line
output which is difficult to understant unless you know how to work iproute2
advanced routing.

> $ debootstrap --include=systemd-container
> 
> You need the above debootstrap pkg for systemd-networkd to work in the
> container.
> 
> Then in the VM and in eatch container, simply enable systemd-networkd.
> 
> 
> If you realy want to do the networking yourself, you will need to create
> the bridge based on the examples found in '/lib/systemd/network'.
> 
> --
> John Doe
> 

-- 
Don't forget to support the ERA apersonment.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web