Running Debian 12, my ethernet card gets an IP using DHCP, and I want to add a VLAN config to that same interface, VLAN 30, and assign it a static IP. Here's my /etc/network/interfaces:
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s25
allow-hotplug enp0s25
iface enp0s25 inet dhcp
#VLAN
auto enp0s25.30
iface enp0s25.30 inet static
address 192.168.30.2
netmask 255.255.255.0
gateway 192.168.30.1
vlan-raw-device enp0s25
No amount of restarting NetworkManager or rebooting gets it to activate the enp0s25.30 interface. The NetworkManger log shows only this line relating to the .30 VLAN:
NetworkManager[2239]: <info> [1718593439.7242] ifupdown: guessed connection type (enp0s25.30) = 802-3-ethernet
Note that my install uses NetworkManager and dhclient to configure interfaces. I don't have ifupdown installed. I don't have anything configured in dhclient.conf because I assumed NetworkManager would notice the 'inet static' and use that.
Also note that I have the following set in my NetworkManager.conf:
[ifupdown]
managed=true
I can get the interface up if I manually run:
ip link add link enp0s25 name enp0s25.30 type vlan id 30
ip addr add 192.168.30.2/24 dev enp0s25.30
ip link set dev enp0s25.30 up
but of course that doesn't persist after a reboot
Any help getting this working would be appreciated.
I got the same problem. Vlan does not activate. Also configures like yours in the interfaces.
I solved this by using systemd-networkd service. interfaces seems to be deprecated in Debian 12 and only used for simple IP setting.
Here is how i did it:
/etc/systemd/network/10-enp0s25.network
Next as the Vlan is no physical device you need to add a virtual "netdev" device first to create the vlan.
/etc/systemd/network/10-enp0s25.30.netdev
To finally create a network for the vlan device. This is done with a network file.
/etc/systemd/network/10-enp0s25.30.network
They need to be 644. Otherwise systemd cant load them you get no network interface configured!
Now you can reboot and watch with a KVM if everything worked as it should.
Vlan interfaces are now stable in my setup.
Using systemd is a workable solution, but it doesn't solve the core problem.
Also, NetworkManager can indeed use /etc/network/interfaces for it's configuration if the
managed=true
flag is set in /etc/NetworkManager/NetworkManager.conf.In my case it turned out NetworkManager already had a config for the ethernet interface in question configured in /etc/NetworkManager/system-connections. Apparently it must look in that location first, causing /etc/network/interfaces to be ignored.
That said, I decided to use ifupdown2 for configuration instead of NetworkManager since this is a server, not a desktop, and will rarely see network changes.