Friday, April 19, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 23595  / 2 Years ago, wed, april 20, 2022, 2:04:52

Running Ubuntu Server 12.04 (no GUI). What would be the best way to make kernel bring a network interface up only if it is physically plugged in? So, if it doesn't exist, just move on with initializing other interfaces (if any) and continue to the login screen, without "waiting for network configuration" delay.



E.g, I have a wireless USB key wlan9 (in /etc/network/interfaces):



auto wlan9
iface wlan9 inet dhcp
wpa-ssid myssd
wpa-psk mykey
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP


I tried allow-hotplug instead of auto, in which case the interface doesn't get initialized automatically during the boot, and I have to do it manually with ifup wlan9. This is not exactly what I'm looking for.



Thank you.


More From » networking

 Answers
0

I've come up with the following solution which doesn't depend on any extra packages:



auto wlan9
iface wlan9 inet manual
wpa-ssid MYSSD
wpa-psk MYKEY
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP
wireless-power off
pre-up if [ -f /sys/class/net/wlan9/operstate ]; then ifconfig wlan9 up; fi
up if [ -f /sys/class/net/wlan9/operstate ]; then dhclient wlan9; fi


While it may not be elegant, it does what I want: skips wlan9 initialization without boot delay if the wireless dongle is not plugged in, otherwise brings it up.


[#30338] Wednesday, April 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
poefor

Total Points: 379
Total Questions: 95
Total Answers: 115

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
;