0

I'm looking to configure an Ethernet interface so that it has its main interface set to DHCP (or statically), but then also build a sub-interface whenever the machine boots or Ethernet is connected. My /etc/network/interfaces configuration is below and the desired behavior occurs on boot, but if the Ethernet cable is disconnected and reconnected, I only get the DHCP address.

It seems like allow-hotplug would be a fix for this, but that doesn't work either. Any idea how to get this to work the way I want? It would really be nice to have a handful of sub-interfaces automatically come up for my test environments.

Thanks!

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp3s0 iface eth0 inet dhcp

auto enp3s0:1 iface enp3s0:1 inet static address 172.16.1.50 netmask 255.255.255.0 gateway 172.16.1.1

  • enp3s0:1 is just the old way of assigning multiple IP addresses to an interface. Please edit your question and describe in more detail what you want to use the "subinterfaces" for. Possibly you want a network namespace and a macvlan for those. – dirkt Jul 19 '21 at 20:21
  • I'm just looking for a single physical interface to have an IP address on two separate networks so that it can communicate on both. I've done some quick research on network namespaces and macvlan but they seem like they are for much more complicated setups. Is there an easier way to accomplish this on boot and each time the interface comes up? – Ryan Wogh Jul 21 '21 at 17:18
  • "I'm just looking for a single physical interface to have an IP address on two separate networks" if you have two "separate networks" on the same LAN segment, then somehow your network design has gone horribly wrong. Have fun with the headaches this is going to cause. That said, with modern kernels can have as many addresses on a single physical interface as you want. Configure with /etc/network/interfaces e.g. as in this answer, just repeat the stanza. – dirkt Jul 22 '21 at 07:29

0 Answers0