0

Is there a possibility to start wpa_supplicant every time when the network connection comes up?

I am able to Secure the network connection manual, but not automatically.

My /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/run/wpa_supplicant
ap_scan=0
network={
    key_mgmt=IEEE8021X
    eap=PEAP
    identity="user"
    password="pasword"
    phase2="autheap=MSCHAPV2"
}

To start the connection with this command:

sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -D wired -i eth0

I tried to edit /etc/network/interfaces --> after reboot no network (also no lo)

I tried to write a small sh script in /etc/network/if-up.d/ --> booting takes about 10 minutes, also no network

Pls help me.

1
  • 1
    I do not understand what you are trying to do. wpa_supplicant is starting on bootup and managed associate, connect, disconnect wifi connections securely with encryption by your choice. So what? – Ingo Apr 11 '20 at 19:09
1

In your question you have wpa_supplicant trying to start Ethernet (eth0) and not WiFi (wlan0) - so I'm a bit baffled and assumed you want to start WiFi if Ethernet is down.

sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -D wired -i eth0

You could try something like this (UNTESTED CODE):

target="8.8.8.8"
router="192.168.1.1"

/bin/ping -q -c1 $target > /dev/null

if [ $? -ne 0 ]
then
    /usr/bin/killall -v wpa_supplicant
    sleep 1
    /usr/bin/killall -v wpa_supplicant
    sleep 2
    /sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -I wlan0
fi

Run this as root via CRON or even in a permanent loop

NOTE: I'm not able to test this at the mo as the family are at home and using the network :-)

You may need to reset the default route - not sure without testing...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.