0

My configuration is:

The files in /etc/systemd/network:

 File:  eth0.1.netdev
 [NetDev]
 Name=enp2s0.1
 Kind=vlan

 [VLAN]
 Id=1


 File: 30-static.network
 [Match]
 MACAddress=b8:ae:ed:eb:b9:2c

 [Network]
 Address=192.168.1.44/24
 Gateway=192.168.1.11
 DNS=8.8.8.8
 DNS=8.8.4.4



File: eth0.network
[Match]
Name=enp2s0

[Network]
VLAN=enp2s0.1
DHCP=no


File: eth2.1.network
[Match]
Name=enp2s0.1
Kind=vlan

[Network]
DHCP=no

[Address]
Address=192.168.1.25/24

Output of ip -d addr show after running sudo systemctl restart systemd-networkd

 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 promiscuity 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
     inet 127.0.0.1/8 scope host lo
        valid_lft forever preferred_lft forever
     inet6 ::1/128 scope host
        valid_lft forever preferred_lft forever
 2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
     link/ether b8:ae:ed:eb:b9:2c brd ff:ff:ff:ff:ff:ff promiscuity 0 numtxqueues 1 numrxqueues 1 gso_max_size 64000 gso_max_segs 64
     inet 192.168.1.44/24 brd 192.168.1.255 scope global enp2s0
        valid_lft forever preferred_lft forever
 3: enp2s0.1@enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
     link/ether b8:ae:ed:eb:b9:2c brd ff:ff:ff:ff:ff:ff promiscuity 0
     vlan protocol 802.1Q id 1 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 64000 gso_max_segs 64
     inet 192.168.1.44/24 brd 192.168.1.255 scope global enp2s0.1
        valid_lft forever preferred_lft forever
     inet6 fe80::baae:edff:feeb:b92c/64 scope link
        valid_lft forever preferred_lft forever

Why am I not getting IP address 192.168.1.25/24 on the vlan interface but getting the same IP address as assigned to the non-VLAN interface?

Sunny
  • 381
  • 1
  • 6
  • 16

1 Answers1

0

I got the solution after reading man page for systemd.network. I changed

File: 30-static.network to
[Match]
Name=enp2s0

[Network]
Address=192.168.1.44/24
Gateway=192.168.1.11
DNS=8.8.8.8
DNS=8.8.4.4

Also renamed it to 10-static.network.

Why? Having a match of MACAddress provides a conflict with the VLAN interface as it too has the same MACAddress. Therefore naming the interface makes it distinct from the VLAN interface. Also, the lexical order of the naming of the files is important. If a Match meets a particular criterion, subsequent files matching the same criterion will be simply ignored.

Sunny
  • 381
  • 1
  • 6
  • 16