Score:0

How to place resolvectl commands in ovpn profile?

lv flag

I've got an ovpn config to connect to private network from Ubuntu 20.04 LTS. But every time after starting the vpn I have to run those commands

resolvectl dns tun0 10.0.0.255
resolvectl domain tun0 "~domain1.com"
resolvectl domain tun0 "~domain2.com"

to make dns work with private subdomains. Is it possible to include those commands into ovpn config and execute them automatically, when I connect to this vpn?

Score:1
af flag

If you are using network-manager-openvpn like me, this could help to resolve the issue persistently:

sudo nmcli connection modify VPN_NAME \                              
    ipv4.dns-search '~domain1.com, ~domain2.com' ipv6.dns-search '~domain1.com, ~domain2.com' ipv4.dns 10.0.0.255

Source: https://ask.fedoraproject.org/t/systemd-resolved-not-querying-dns-server-set-by-openvpn/9696/9

I didn't try the part regarding the dns server. Be careful. This overwrites pushed settings. If you want to use some of the domains as search domains, simply omit the '~'.

Score:0
in flag

You may use --up and --down parameters (or up / down configuration directives) to point to a script, which will be run after establishing / closing connection. You may not use shell expressions (like --up 'resolvectl dns tun0 10.0.0.255 && resolvectl domain tun0 "~domain1.com"') - it won't work.

Also, to allow OpenVPN calling external scripts, please pass --script-security 2.

Please read the official OpenVPN documentation shall you have more questions.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.