How can I use openconnect in the background
To connect:
sudo openconnect --background <...>
To disconnect:
sudo killall -SIGINT openconnect
Using SIGINT
gives the background process time to clean up the DNS configuration and exit gracefully.
According to the Openconnect documentation, the option you would want to try would be:
-b,--background
Continue in background after startup
Yes. -b
is the option. But that just leads to the next issue: A clean disconnect then is not possible anymore. I mean, the only way to exit openconnect
when it is in background is to kill the process. But that causes a name service problem. All DNS requests are still sent to the name servers that were learned during the VPN establishment process, but they are not reachable anymore after disconnect. Only workaround is to shut down the whole interface and take it up again.