ifupdown-ng cheatsheet


  • Assume we have a device that has four ethernet ports(eth0, eth1, eth2, eth3, respectively)
  • For WAN, we will use eth0 facing modem to connect to ISP via PPP over Ethernet.
  • We will use eth2 and eth3 to build a bonding interface, bond0, to do 802.3ad LACP.
  • For LAN, we will use bond0.70 interface, which is based on bond0 interface.
  • For management network, we use vrf-mgmt0 with kernel table id 10 as Management VRF, there will be bond0 and one WireGuard interface attached to it.
  • For DN42 Network, we use vrf-dn42 with kernel table id 42 as DN42 VRF, there will be bond0.342 and several WireGuard interfaces for peering attached to it.
  • Eth1 port is unused.

So this configuration file includes PPPoE, VRF, Bonding(802.3ad LACP), VLAN, WireGuard interface configuration.
And it is mainly taken from my own router configuration.
For WireGuard and PPPoE configuration file, please refer to their own manpages and documentations respectively.


# Here begins Management LAN
## Management VRF
auto vrf-mgmt0
iface vrf-mgmt0
    pre-up ip link add $IFACE type vrf table 10
    up ip link set dev $IFACE up

## Management VPN to access it
auto vpn-mgmt0
iface vpn-mgmt0
    requires vrf-mgmt0
    wireguard-config-path /etc/wireguard/vpn-mgmt0.conf
    pre-up ip link set $IFACE master vrf-mgmt0
    mtu 1412

## Bring up eth2 nd eth3
auto eth2
iface eth2 inet manual

auto eth3
iface eth3 inet manual

## Attach bond0 to Management VRF.(it's untagged)
auto bond0
iface bond0
    use bond
    requires eth2 eth3 vrf-mgmt0
    bond-members eth2 eth3
    bond-mode 802.3ad
    bond-xmit-hash-policy encap3+4
    up ip link set $IFACE master vrf-mgmt0

# LAN setup with VLAN
auto bond0.70
iface bond0.70 inet static

# eth0 facing modem/wan
auto eth0
iface eth0 inet static

# PPPoE interface
auto ppp0
iface ppp0 inet ppp
    requires bond0 bond0.70 eth0
    pre-up /sbin/ip link set eth0 up
    provider dsl-provider

# DN42 begins here
## VRF interface for DN42
auto vrf-dn42
iface vrf-dn42 inet manual
    pre-up ip link add $IFACE type vrf table 42
    up ip link set dev $IFACE up

## Dummy device carrying loopback address.
auto dummy1
iface dummy1 inet manual
    pre-up ip link add $IFACE type dummy
    pre-up ip link set $IFACE master vrf-dn42
    up ip link set dummy1 up
    address fd0b:da1a:9768:300::1/128
    post-down ip link del dummy1
    requires vrf-dn42

## DN42 Server LAN:
auto bond0.421 inet static
    requires vrf-dn42 bond0
    up ip link set $IFACE master vrf-dn42
auto bond0.421 inet6 static
    post-up ip addr add fd0b:da1a:9768:301::1/64 dev $IFACE

## DN42 Peering:
auto dn42-someone
    wireguard-config-path /etc/wireguard/dn42-someone.conf
    address fe80::2032/64
    pre-up ip link set $IFACE master vrf-dn42
    post-up ip a a peer dev $IFACE
    mtu 1412

## If you are using OSPF with WireGuard tunnels then you will need to manually add link local IPv6 address to it.
## Personally I use GRETAP over IPSec for encryption.
auto dn42-somewhere
iface dn42-somewhere inet static
    pre-up ip link add $IFACE type gretap local remote ttl 255
    pre-up ip link set $IFACE master vrf-dn42
    post-down ip link del $IFACE
    mtu 1380
iface dn42-somewhere inet6 auto
    address fd0b:da1a:9768:300::1/128


  • Note that WireGuard configuration file has no Address , Table , Post/Pre Up/Down options, since wg tool only handles jobs setting config for WireGuard interfaces(that is, setting interface’s own privatekey, listenport, peer’s allowedips with its corresponding publickey, endpoints as well as presharedkey, if exists).
  • We assume that all WireGuard configuration files are in /etc/wireguard/
  • PPPoE IPv6 configuration: It is feasible to put dhcpcd ppp0 and dhcpcd ppp0 -k to hook scripts in /etc/ppp/.

That’s all. Thanks for your reading.

Built with Hugo
Theme Stack designed by Jimmy