TransWikia.com

Content of /etc/network in Alpine Linux image

Unix & Linux Asked by Francesco Lucianò on October 19, 2020

I have an Alpine Linux image installed on a docker container. I was exploring it, and doing ls -lR /etc/network I had this result:

/etc/network/:
total 24
drwxr-xr-x    2 root     root          4096 Jan 16  2020 if-down.d
drwxr-xr-x    2 root     root          4096 Jan 16  2020 if-post-down.d
drwxr-xr-x    2 root     root          4096 Jan 16  2020 if-post-up.d
drwxr-xr-x    2 root     root          4096 Jan 16  2020 if-pre-down.d
drwxr-xr-x    2 root     root          4096 Jan 16  2020 if-pre-up.d
drwxr-xr-x    2 root     root          4096 Jan 16  2020 if-up.d
/etc/network/if-down.d:
total 0
/etc/network/if-post-down.d:
total 0
/etc/network/if-post-up.d:
total 0
/etc/network/if-pre-down.d:
total 0
/etc/network/if-pre-up.d:
total 0
/etc/network/if-up.d:
total 4
-rwxrwxr-x    1 root     root           218 Jan 15  2020 dad

Inside /etc/network/if-up.d/dad I found:

#!/bin/sh
# Block ifup until DAD completion
# Copyright (c) 2016-2018 Kaarle Ritvanen
has_flag() {
    ip address show dev $IFACE | grep -q " $1 "
}
while has_flag tentative && ! has_flag dadfailed; do
    sleep 0.2
done

I’m trying to understand why those folders exist and which is the purpose of dad. I searched on internet, but I didn’t find anything useful. I expected to find something like /etc/network/interfaces, but I can’t understand what’s the purpose of this all. Can somebody explain it?

One Answer

Those folders are hooks for ifupdown, there are a lot ifupdown implementation, but alpine default one is busybox's, you can check the source here networking/ifupdown.c.

busybox only handle auto interface, support these builtin types.

  • inet
    • manual wvdial ppp static bootp dhcp loopback
  • inet6
    • static manual loopback v4tunnel

ifupdown has tow $MODE, up,down, for each mode, has tow hook, pre-, post-.

Folders contain the hook script will called by run-parts, check the code process.

You can use the hook to implement extra type, to make config easier, like bonding provided by bonding package. All existing script is here.

dad is provided by busybox for IPv6 Enhanced Duplicate Address Detection.

Correct answer by wener on October 19, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP