RTNETLINK answers: Device or resource busy; ifup: failed to bring up wlxf4f26d13b2bd - linux

I'm trying to configure the network via /etc/network/interfaces here's my file:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug usb0
iface usb0 inet dhcp
# The wifi network interface
iface wlxf4f26d13b2bd inet manual
hwaddress ether 2a:bf:x9:53:38:9d
wpa-driver nl80211
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
but when I try to activate the device with ifup wlxf4f26d13b2bd I get:
> RTNETLINK answers: Device or resource busy ifup: failed to bring up
> wlxf4f26d13b2bd
I'm not using NetworkManager.
This is the verbose output of ifup:
ifup -v wlxf4f26d13b2bd
ifup: configuring interface wlxf4f26d13b2bd=wlxf4f26d13b2bd (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/macchanger
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
wpa_supplicant: terminating wpa_supplicant daemon via pidfile /run/wpa_supplicant.wlxf4f26d13b2bd.pid
Stopped /sbin/wpa_supplicant (pid 1568).
wpa_supplicant: removing /run/sendsigs.omit.d/wpasupplicant.wpa_supplicant.wlxf4f26d13b2bd.pid
wpa_supplicant: wait for wpa_cli to attach
wpa_supplicant: wpa-driver nl80211
wpa_supplicant: /sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wlxf4f26d13b2bd.pid -i wlxf4f26d13b2bd -W -D nl80211 -c /etc/wpa_supplicant/wpa_supplicant.conf -C /run/wpa_supplicant
Starting /sbin/wpa_supplicant...
wpa_supplicant: creating sendsigs omission pidfile: /run/sendsigs.omit.d/wpasupplicant.wpa_supplicant.wlxf4f26d13b2bd.pid
wpa_supplicant: ctrl_interface socket located at /run/wpa_supplicant/wlxf4f26d13b2bd
/sbin/ip link set dev wlxf4f26d13b2bd address 2a:bf:x9:53:38:9d
RTNETLINK answers: Device or resource busy
ifup: failed to bring up wlxf4f26d13b2bd

I solved the issue. The problem was that it was trying to change the MAC address after the wpa_supplicant configuration; The order of commands in the file is not respected. The simple solution is either to set the mac address with pre-up macchanger -m inside the iface stanza or to invoke macchanger before wpa-supplicant.
Thanks!

Related

Check NetworkManager is DHCP or Static with command line Ubuntu

How can I check the GUI network setting is set DHCP or Static with command line? for the active and connected interface in Ubuntu 18.04
I want one line command like grep give me static/dhcp or true/false
Can use ip command to check interface you're interested in.
E.g. to check the interface eth0:
if ip -6 addr show eth0 | grep -q dynamic; then
echo "Uses DHCP addressing"
else
echo "Uses static addressing"
fi
-6 option is for checking IPv6 interface. You can use -4 for IPv4.
nmcli -f ipv4.method con show
If the output is auto, then it is DHCP.
If the output is manual, then it is static.
or
cat /etc/network/interfaces
DHCP enabled
auto eth0
iface eth0 inet dhcp

How to get bridge support with /etc/network/interfaces?

There are some linux distros, where it is possible to configure a bridge in /etc/network/interfaces. As explained for example here, it is enough to use this to form a bridge:
iface eth0 inet manual
iface eth1 inet manual
iface br0 inet dhcp
bridge_ports eth0 eth1
I am building a custom linux image using yocto. In my image this is not working. Yocto version is morty, which is already 3 years old.
So, what I need to do to get this functionality? Is it enough to get a newer version of the ifupdown package (I assume that this package provides this functionality)?
I installed the bridge-utils package, and I could add a bridge using brctl, as explained here:
brctl addbr br0
brctl addif br0 eth0 eth1
but I do not want to do it manually. I would like to do it by modifying /etc/network/interfaces, because then the changes are saved between reboots.
Do you use systemd?
If so, try a bbappend of systemd-machine-units, e.g.:
FILESEXTRAPATHS_prepend := "${THISDIR}/systemd-machine-units:"
SRC_URI += " \
file://10-eth0.network \
file://10-eth1.network \
"
do_install_append() {
for file in $(find ${WORKDIR} -maxdepth 1 -type f -name *.network); do
install -m 0644 "$file" ${D}${systemd_unitdir}/network/
done
}

Pass IP-address to cloud-init metadata

I am searching for a way to pass a ip-address to cloud-init metadata. So when my qcow boots, it does not have to wait for 120 - 180 seconds to boot.
Currently I've created a workaround by adding IP-address information to the userdata part of cloud-init. The con is, it does take some time because cloud-init userdata is only executed after booting the VM.
echo -e "
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
\taddress $address
\tnetmask $netmask
\tgateway $gateway
\tdns-nameservers $dnsnameservers
" > /etc/network/interfaces
ifdown eth0; ifup eth0
Currently to set the hostname in cloud-init metadata, I've already obtained this part:
cat > $config_dir/meta-data <<-EOF
instance-id: $uuid
hostname: $hostname
local-hostname: $hostname
EOF
But I need something more solid, more concrete because the cloud-init documentation is very vague
EDIT: I've seen that it is possible because Openstack can do it.
It is possible by using the following format:
network-interfaces: |
auto lo
iface lo inet loopback
iface eth0 inet static
address xxx.xxx.xxx.xxx (static ip)
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx (gateway ip, usually ip address of router)
You basically write out the configuration you want your interfaces to have as an interfaces file would look as long as you have 'network-interfaces: |'
Hope that answers your question!

Dynamic Switching of WiFi using a shell program in Raspberry Pi / Ubuntu / Debian

How can I check in a shell script, whether the system is connected to WiFi-1 and if not connected, connect to WiFi-2? I tried using wpa_supplicant and interfaces configurations, but not working as expected. I followed this tutorial
If there is any other way of doing this, please let me know.
/etc/network/interfaces file
auto eth0
iface eth0 inet6 manual
pre-up ip link set dev eth0 up || true
wpa-iface eth0
wpa-driver wired
wpa-conf /etc/wpa_supplicant/wpa_supplicant_wired.conf
pre-down /etc/netplug/netplug eth0 out >/dev/null 2>&1 || true
post-down ip link set dev eth0 down || true
auto wlan0
iface wlan0 inet manual
pre-up ip link set dev wlan0 up || true
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
wpa-driver wext
pre-down /etc/netplug/netplug wlan0 out >/dev/null 2>&1 || true
post-down ip link set dev wlan0 down || true
# open is specific (IPv6 only) so I just stop dhcp via netplug
iface open inet manual
up /etc/netplug/netplug wlan0 out >/dev/null 2>&1 || true
iface default inet manual
up /etc/netplug/netplug wlan0 in >/dev/null 2>&1 || true
down /etc/netplug/netplug wlan0 out >/dev/null 2>&1 || true
I think you may have already found the solution by now. Anyway as a workaround to do this you can install Network manager (supports all debian distributions including ubuntu/raspbian/etc)
sudo apt-get install network-manager
And then add required network configuration to /etc/NetworkManager/system-connections folder.
Sample configuration for a wifi network connection as follows:
[connection]
id=milanWiFi
uuid=56439211-1067-4334-b199-b73ceed32d83
type=802-11-wireless
[802-11-wireless]
ssid=milanWiFi
mode=infrastructure
mac-address=84:3A:4B:9B:CF:66
security=802-11-wireless-security
[802-11-wireless-security]
key-mgmt=wpa-psk
auth-alg=open
psk=milan123
[ipv4]
method=auto
[ipv6]
method=auto
Here, id is an unique name for your connection and you can obtain uuid by calling,
uuidgen command in the console.
For you to get the available wifi connections, you can use
sudo iw dev wlan0 scan
and there you can see the relevant details about the connections. What you have to do is to grab the details out of it and create the configuration file.

linux device driver for pure ipv6 device

I am currently designing a linux driver for a pure IPv6 driver. Is there any way to make the kernel module only support IPv6 and can only be assigned IPv6 address? What is the commands in linux to set the address?
Thanks
Adding IP:
Using ip command:
$sudo /sbin/ip -6 addr add 2001:0db8:0:f101::1/64 dev eth0
Using ifconfig command:
$sudo /sbin/ifconfig eth0 inet6 add 2001:0db8:0:f101::1/64
Deleting IP:
Using ip
$sudo /sbin/ip -6 addr del 2001:0db8:0:f101::1/64 dev eth0
Using ifconfig
$sudo /sbin/ifconfig eth0 inet6 del 2001:0db8:0:f101::1/64

Resources