2

I am currently working on setting up a wireless mesh network using babeld as the routing algorithm. The documentation is very sparse, and most of the configuration guides I've seen online are using the deprecated ifconfig command.

I could obviously just install ifconfig and run the commands as-is. But, if possible, I would prefer to not create an unnecessary dependency on ifconfig, and just use the built-in iproute2-based commands instead. So I have been converting ifconfig commands I'm coming across into their corresponding ip versions (e.g. ifconfig eth0 up --> ip link set eth0 up)

However, today I came across the following babeld configuration script:

ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc essid reseaulibre.ca ap 02:CA:FF:EE:BA:BE channel 9
ifconfig wlan0 up
avahi-autoipd wlan0
ifconfig wlan0:avahi netmask 255.255.255.255
babeld -D wlan0:avahi wlan0

... and I don't understand how to convert the following line into a corresponding ip command:

ifconfig wlan0:avahi netmask 255.255.255.255

What is an equivalent command using ip, that would work in the context of the above configuration script?

1 Answer 1

1

This seems to be one thing there's no straight replacement for with ip.

One solution is:

IPNM=$(ip a sh dev wlan0:avahi scope global | awk  '/inet / {print $2}')
IP=${IPNM/\/*})
ip a add $IP/32 dev wlan0:avahi
ip a del $IPNM dev wlan0:avahi

This first extracts the IP address including netmask from the output of ip addr show and stores that in $IPNM. After that the subnet part is stripped and stored in $IP.

Now you can add the IP address with the desired netmask to the device, and then remove the old IP/netmask from the device.

1
  • 1
    Actually the equivalent of interface alias is the undocumented option label (as in ip address show wlan0 label wlan0:avahi). But what doesn't seem possible is to add an IP which will have both secondary and label flags to do exactly (via netlink) what is doing ifconfig (via ioctl) and stay compatible with it. I suppose it's just a limitation of the ip command's syntax for a feature that isn't really useful. Commented Aug 29, 2018 at 11:52

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.