0

I want to configure a vlan interface by using a file in /etc/network/interfaces.d/, e.g.

vlan1cfg:

auto vlan1
iface vlan1 inet static
    address <some addr>
    netmask <some mask>
    vlan-raw-device <some bridge>
    post-up route add -net 224.0.0.0/4 vlan1
    post-up ip addr add <some addr>/25 dev vlan1
    post-up ip addr add <some addr>/25 dev vlan1

and conditionally on some systems I want to add an additional address to this interface by using an additional config file, e.g.

vlan1cfgadd:

auto vlan1
iface vlan1 inet static
    post-up ip addr add <some other addr>/25 dev vlan1

If I issue ifquery -v vlan1 it reports the parsing of all files, but only the commands of 1st parsed file are reported. I thought the commands are collected from all files.

I want to do this setting in the network configuration at one place, is that possible somehow ?

guntbert
  • 631
  • 9
  • 21

1 Answers1

2
  1. You should use the source or source-directory statements to include additional files of interfaces configurations. On the fresh systems by default there is the line source-directory /etc/network/interfaces.d/*, that force incuding of all files under corresponded directory.

  2. You don't need additional files. All configurations can be located at one place. Small example:

auto vlan1
iface vlan1 inet static
    vlan-raw-device brX
    vlan-id 1
    address <some-addr>/<prefix-len>
    up ip addr add <some-addr-2>/<prefix-len> dev ${IFACE} || true
    up ip addr add <some-addr-3>/<prefix-len> dev ${IFACE} || true
    up ( test -f /var/run/vlan1.extra.address && ip addr add <some-other-addr>/<prefix-len> dev ${IFACE} ) || true
    post-up ip route replace 224.0.0.0/4 dev ${IFACE} || true

In this example additional address usage depends on existing of the /var/run/vlan1.extra.address file.

Anton Danilov
  • 5,082
  • 2
  • 13
  • 23