Compare ifupdown2 Commands with ifupdown Commands
ifupdown2
is the network interface manager for Cumulus Linux. It is an updated version of the original ifupdown
in both Cumulus Linux and Debian. This article demonstrates the differences between the two in how you configure interfaces.
View All ifupdown2 Configuration Keywords and Options
To determine which options you can configure for the bridge settings or bond settings, run:
ifquery --syntax-help
Loopback Interfaces
ifupdown2
lets you configure IP addresses on loopback interfaces:
ifupdown | ifupdown2 |
---|---|
|
|
Layer 2 Interfaces - Physical
In the original ifupdown
, when the method is manual
, you had to
specify up link set $IFACE up
and down link set $IFACE down
in the
configuration. ifupdown2
does this for you automatically.
ifupdown | ifupdown2 |
---|---|
|
|
The following is some debug code:
sudo ifup -d swp19
DEBUG: args = Namespace(CLASS=None, all=False, debug=True, excludepats=None, force=False, iflist=['swp19'], jobs=-1, noact=False, nocache=False, perfmode=False, printdependency=None, quiet=False, verbose=False, withdepends=False)
DEBUG: creating ifupdown object ..
INFO: loading builtin modules from /usr/share/ifupdownaddons
INFO: looking for user scripts under /etc/network
INFO: loading scripts under /etc/network/if-pre-up.d ...
INFO: loading scripts under /etc/network/if-up.d ...
INFO: loading scripts under /etc/network/if-post-up.d ...
INFO: loading scripts under /etc/network/if-pre-down.d ...
INFO: loading scripts under /etc/network/if-down.d ...
INFO: loading scripts under /etc/network/if-post-down.d ...
DEBUG: reading interfaces file /etc/network/interfaces
WARNING: template engine mako not found. skip template parsing ..
DEBUG: populating dependency info for ['swp19']
DEBUG: run_without_dependents for ops ['pre-up', 'up', 'post-up'] for ['swp19']
DEBUG: swp19: pre-up : running module bridge
DEBUG: swp19: pre-up : running module mstpctl
DEBUG: swp19: pre-up : running module vlan
DEBUG: swp19: pre-up : running module address
DEBUG: swp19: pre-up : running module usercmds
DEBUG: running cmd 'ethtool -s swp19 speed 1000'
INFO: Executing ethtool -s swp19 speed 1000
DEBUG: swp19: pre-up : running script /etc/network/if-pre-up.d/ethtool
DEBUG: Executing /etc/network/if-pre-up.d/ethtool
DEBUG: swp19: up : running module dhcp
DEBUG: swp19: up : running module link
INFO: Executing ip link set dev swp19 up <===== Run for you now!
DEBUG: swp19: up : running script /etc/network/if-up.d/ethtool
DEBUG: Executing /etc/network/if-up.d/ethtool
DEBUG: swp19: up : running script /etc/network/if-up.d/ip
DEBUG: Executing /etc/network/if-up.d/ip
DEBUG: swp19: up : running script /etc/network/if-up.d/mountnfs
DEBUG: Executing /etc/network/if-up.d/mountnfs
DEBUG: swp19: up : running script /etc/network/if-up.d/openssh-server
DEBUG: Executing /etc/network/if-up.d/openssh-server
DEBUG: swp19: post-up : running module usercmds
Layer 2 Interfaces - Trunk
With ifupdown2
, you do not need to define subinterfaces to add to the trunk. Just add it under the bridge interface.
Notice that the example uses bridge-ports
instead of mstpctl-ports
.
By default, bridge-stp
turns on Rapid Spanning Tree.
ifupdown | ifupdown2 |
---|---|
|
|
Layer 2 Bond Interface - with Trunking
The following shows you how to configure bonds with trunking under ifupdown2
.
ifupdown | ifupdown2 |
---|---|
|
|
Layer 2 Trunk - Port Ranges
The glob keyword replaces regular expressions for creating port ranges, because it does not require mentioning the interfaces in /etc/network/interfaces
. You can mention multiple glob statements in the stanza so you can configure a discontiguous port range.
ifupdown | ifupdown2 |
---|---|
|
|
IPv6 Address Assignment
ifupdown2 does not require configuring IPv6 addresses under an independent inet6 section. You do all interface configuration under the same section. The same is true for the loopback configuration as well.
Single IPv6 Address
ifupdown | ifupdown2 |
---|---|
|
|
Multiple IPv6 Addresses
ifupdown | ifupdown2 |
---|---|
|
|
Setting Speed, Duplex and Auto-negotiation on a Port
ifupdown2
now supports keywords to set the speed, duplex and auto-negotiation.
ifupdown | ifupdown2 |
---|---|
|
|
Setting the Port Description
ifupdown2
lets you configure the IP address on loopback interfaces.
ifupdown | ifupdown2 |
---|---|
|
|
# ip link show swp1
3: swp1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 500
link/ether 08:9e:01:ce:dc:c2 brd ff:ff:ff:ff:ff:ff
alias customerA
Using the “source” Keyword to Place Interface Configuration in Files Other than /etc/network/interfaces
This is useful for automation. This example shows how Ansible writes individual port configs into the /etc/network/ansible/
directory with ifupdown2
.
To view all the configuration, run ifquery -a
.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
source /etc/network/ansible/*
# tree /etc/network/ansible
/etc/network/ansible
|-- swp1
|-- swp2
|-- swp3
`-- swp4
0 directories, 4 files
# ifquery -a
auto lo
iface lo inet loopback
address 10.3.3.3/32
address 10:3:3::3/128
auto eth0
iface eth0 inet dhcp
auto swp1
iface swp1
link-speed 1000
auto swp2
iface swp2
link-speed 1000
auto swp3
iface swp3
link-speed 10000
auto swp4
iface swp4
address 10.200.1.1/24
Creating the Default Configuration Using Mako
Mako is a templating engine that you can use to generate the /etc/network/interfaces
configuration. Use it to generate a default configuration. The example below shows how to set defaults for bonds. By default, ifupdown2
reads Mako files in the /etc/network/ifupdown2/templates
directory. You can change this location in the /etc/network/ifupdown2/ifupdown2.conf
. To view the expanded configuration, like a running config, run ifquery bond0
or ifquery -a
.
ifupdown2 - /etc/network/interfaces | ifupdown2 - /etc/network/mako/bond_defaults |
---|---|
|
|
ifquery Output
#sudo ifquery -a
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto swp1
iface swp1
auto swp2
iface swp2
auto bond0
iface bond0
bond-slaves swp1 swp2
bond-miimon 100
bond-min-links 1
bond-mode 802.3ad
bond-xmit-hash-policy layer3+4
bond-lacp-rate 1