Web lists-archives.com

Re: How does one create virtual ethernet devices with modern tools on Debian 8 (jessie)?




Tom Browder:

  # added alias IPv4s:
  up   ip addr add 142.54.186.3/29 dev $IFACE label $IFACE:0
  down ip addr del 142.54.186.3/29 dev $IFACE label $IFACE:0

Ironically, the "modern tools" aspect is the thing that you are in fact aiming to eliminate here.  /etc/network/interfaces is best treated as an entirely descriptive mechanism, with as little imperative stuff in it as can be arranged.  Here, you are getting rid of the imperative explicit invocations of the ip command, the "modern tool" as you mention, and replacing them with the descriptive "stanzas" that /etc/network/interfaces already has as a mechanism for non-imperatively describing multiple IPv4/IPv6 addresses on a single eth0 interface.

ifup and ifdown are best thought of as translators, as their manual page implies.  They take what is in /etc/network/interfaces and translate it into the necessary sequences of imperative commands for actually doing the job, which they run under the covers. Those underlying commands can include bootpc, avahi-autoipd, settle-dad.sh, pon, poff, wvdial, dhclient, dhclient3, pump, udhcpc, dhcpd, kill, ip, and (sic!) ifconfig, all invoked with various parameters calculated from the /etc/network/interfaces description.

They aren't the only translators for that file.  For example, here's what happens when one runs your proposed non-imperative /etc/network/interfaces (with the typing errors mentioned elsewhere cleaned up) through mine, which translates from that description into (roughly) the rc.conf configuration format for FreeBSD/TrueOS:

JdeBP % sudo redo -C /etc/system-control/convert/ rc.conf
Password:
redo: INFO: rc.conf: Redone.
JdeBP % sed -ne '/etc.network.interfaces/,/sysrc:/p' /etc/system-control/convert/rc.conf
# Converted from /etc/network/interfaces:
network_interfaces="lo eth0 "
ifconfig_lo="AUTO inet  127.0.0.1 "
ifconfig_eth0="AUTO inet  142.54.186.2 netmask 255.255.255.248 gateway 142.54.186.1 "
ifconfig_eth0_ipv6="inet6  2604:4300:a:95::2 netmask ffff:ffff:ffff:ffff:: "
ifconfig_eth0_aliases="inet 142.54.186.3
inet 142.54.186.4
inet 142.54.186.5
inet 142.54.186.6
inet6 2604:4300:a:95::3
inet6 2604:4300:a:95::4
inet6 2604:4300:a:95::5
inet6 2604:4300:a:95::6"
# dump by sysrc:
JdeBP %