VLAN Setup

Hello guys, I’ve been running dietpi for years and everything was great. I just bought an intel nuc for home so I moved my rpi3b+ to my office to run some apps.
I did a fresh install

G_DIETPI_VERSION_CORE=7
G_DIETPI_VERSION_SUB=8
G_DIETPI_VERSION_RC=2
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
G_LIVE_PATCH_STATUS[0]='applied'
G_LIVE_PATCH_STATUS[1]='applied'
G_LIVE_PATCH_STATUS[2]='applied

bullseye

Linux RPi3 5.10.63-v7+ #1488 SMP Thu Nov 18 16:14:44 GMT 2021 armv7l GNU/Linux'

I am having some issues, and I am ready to start over by re-flashing the SD, and I hoped I stayed with dietpi.

Installed vlan package, made configuration in interfaces.d as follows:

auto eth0.2000
iface eth0.2000 inet manual
  vlan-raw-device eth0.2000

interface eth0.2000
static ip_address=192.168.200.5/24
static routers=192.168.200.1
static domain_name_servers=1.1.1.1

It doesn’t seem to get an IP address… I really don’t mind about that though since docker macvlan is working on eth0.2000

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:9b:2b:e5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.50/24 brd 192.168.100.255 scope global eth0
       valid_lft forever preferred_lft forever
3: eth0.2000@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether b8:27:eb:9b:2b:e5 brd ff:ff:ff:ff:ff:ff
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:74:38:50:0b brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
5: br-bf2efa5d9bee: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:9f:ea:81:50 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-bf2efa5d9bee
       valid_lft forever preferred_lft forever
7: veth186bf12@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-bf2efa5d9bee state UP group default
    link/ether 4e:c1:d2:cd:7d:d8 brd ff:ff:ff:ff:ff:ff link-netnsid 0

Also when I ssh to the rpi, i get a timeout : curl: (28) Resolving timed out after 3000 milliseconds (DietPi info), so I have to wait before using cli.

Dec 10 10:33:19 RPi3 kernel: 8021q: 802.1Q VLAN Support v1.8
Dec 10 10:33:19 RPi3 ifup[417]: RTNETLINK answers: File exists
Dec 10 10:33:19 RPi3 ifup[287]: ifup: failed to bring up eth0.2000
Dec 10 10:33:19 RPi3 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE

Dec 10 10:33:19 RPi3 systemd[1]: networking.service: Failed with result 'exit-code'.
Dec 10 10:33:19 RPi3 systemd[1]: Failed to start Raise network interfaces.

Dec 10 10:33:19 RPi3 systemd[1]: Reached target Network.
Dec 10 10:33:19 RPi3 systemd[1]: Reached target Network is Online.
Dec 10 10:33:19 RPi3 systemd[1]: Starting containerd container runtime...
Dec 10 10:33:19 RPi3 systemd[1]: Started DietPi-PostBoot.
Dec 10 10:33:19 RPi3 systemd[1]: Starting OpenBSD Secure Shell server...
Dec 10 10:33:19 RPi3 systemd[1]: Starting Permit User Sessions...
Dec 10 10:33:19 RPi3 systemd[1]: Finished Permit User Sessions.
Dec 10 10:33:19 RPi3 systemd[1]: Started Getty on tty1.
Dec 10 10:33:19 RPi3 systemd[1]: Reached target Login Prompts.
Dec 10 10:33:20 RPi3 sshd[448]: Server listening on 0.0.0.0 port 22.
Dec 10 10:33:20 RPi3 sshd[448]: Server listening on :: port 22.

Can you please tell me the correct way to configure VLANS? (e.g. eth0 dhcp or static and eth0.2000 static)

You’d need to configure the interfaces files the same way as in debian and not use the dietpi-config to configure networking as it will overwrite your settings.
If that doesn’t work, make sure that the upstream device is tagging the frames properly and uses the correct pvid for the untagged frames.

if I edit the file /etc/network/interfaces
will it persist after updating dietpi ?

Either way, at the top of the file there is this:

# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

To be honest I never managed to create some working drop-in in interfaces.d/
I made the changes directly in interfaces file and as long as I didn’t invoke any network changes in dietpi-config, it worked fine.
Maybe MichaIng or Joulinar can say for sure if it will persist an upgrade.

Yes an update will not overwrite entries in network/interfaces. It should stay untouched, as long as you don’t use dietpi-config to adjust network settings.

My interfaces file looks like this now:

# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.100.50
netmask 255.255.255.0
gateway 192.168.100.1
#dns-nameservers 1.1.1.1

# WiFi
#allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.200.5
netmask 255.255.255.0
gateway 192.168.200.1
#dns-nameservers 9.9.9.9 149.112.112.112
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

So I can remove the drop-in configuration file, and directly add the vlan here?

You can try to add a drop-in or edit the interfaces directly.

I did the drop-in method, which disregards the IP settings and just creates an interface eth0.2000 without setting any IP (either dhcp or static).
So probably, I should only edit interfaces and never touch dietpi-config for interfaces

It depends on which kind of interface you want to create/configure. dietpi-config always configures ethX and/or wlanX, depending on which one is enabled. If you create a VLAN for eth0, then obviously eth0 must not be configured with DHCP or static IP the way dietpi-config does(?), hence you need to disable Ethernet in dietpi-config and define it the required way in e.g. /etc/network/interfaces.d/eth0.conf. If you add a second network or WiFi adapter for internal/bridge/VLAN network or so, you don’t need to worry about dietpi-config. It keeps configuring only e.g. eth0 for internet access while you can configure eth1 in e.g. /etc/network/interfaces.d/eth0.conf.

But I agree that we need a per-interface config possibility, so that individual interfaces, like eth0, eth1, wlan0 etc can be enabled/disabled/configured instead of only Ethernet/WiFi where it is not obvious which interface/adapter it actually refers to.