Make Linux autoconnect to WiFi (as I did manually)

I've installed arch linux on VirtualBox (black arch if it does matter). Now I was struggling to get wifi work. I have TP-Link WN722n and Network Adapter set to Bridged and I chose my TP-Link from there. I was able to connect to Wi-Fi using a script written by myself (which mimicks the commands from blackarch-installer):

wpasup="$(mktemp)"
dhcp_opts="-h noleak -i noleak -v ,noleak -I noleak"
NET_IF="wlp0s11u1"
ip link set wlp0s11u1 down
ip link set wlp0s11u1 up
wpa_passphrase "TEST-WIFI" "<password>" > ${wpasup}
wpa_supplicant -B -c ${wpasup} -i ${NET_IF}
sleep 10
dhcpcd ${dhcp_opts} -i ${NET_IF}

So it works. But when I plug out and plug in my TP-Link device (adding it then from devices menu to my VM of course) it doesn't work anymore (ping gives Temporary failure in name resolution) and it even remembers my configuration under iwconfig (ESSID is still TEST-WIFI etc.), but yeah, it does not ping. And then I run dhcpcd again, it does it job and I can ping again.

So my question is not how to connect to Wi-Fi but how to make linux remember my configuration (like it happens in Windows) or autoconnect (like in Windows) to Wi-Fi network.

1 answer

  • answered 2018-06-18 01:56 Hammatt

    Assuming that black arch works the same way as normal arch...

    The documentation you're looking for is found here: https://wiki.archlinux.org/index.php/netctl

    So to summarise, you will need to copy a file from /etc/netctl/examples/ (whichever is closest to what you need) to /etc/netctl/ and edit it as appropriate.

    you will then need to run the command netctl start {whatever you named your profile} and then to enable it to start automatically, use netctl enable {whatever you named your profile}

    I hope this helps. please let me know if you have issues.