I solved the problem but the solution is ugly...
Thanks to:
- https://forum.openwrt.org/viewtopic.php?pid=118310#p118310
- https://github.com/StreisandEffect/streisand/wiki/Setting-an-OpenWrt-Based-Router-as-OpenVPN-Client
The solution is to create two scripts: /etc/openvpn/updns
:
#!/bin/sh
mv /tmp/resolv.conf.auto /tmp/resolv.conf.auto.hold
echo $foreign_option_1 | sed -e 's/dhcp-option DOMAIN/domain/g' -e 's/dhcp-option DNS/nameserver/g' > /tmp/resolv.conf.auto
echo $foreign_option_2 | sed -e 's/dhcp-option DOMAIN/domain/g' -e 's/dhcp-option DNS/nameserver/g' >> /tmp/resolv.conf.auto
echo $foreign_option_3 | sed -e 's/dhcp-option DOMAIN/domain/g' -e 's/dhcp-option DNS/nameserver/g' >> /tmp/resolv.conf.auto
and /etc/openvpn/downdns
:
#!/bin/sh
mv /tmp/resolv.conf.auto.hold /tmp/resolv.conf.auto
And add them to .ovpn files with this:
script-security 2 system
up "/etc/openvpn/updns"
down "/etc/openvpn/downdns"
Pretty ugly...
I understand the /etc/openvpn/updns
script update DNS in the file /tmp/resolv.conf.auto but what is $foreign_option_1, $foreign_option_2 and $foreign_option_3?
And why the DNS are not updated automatically?
If anyone knows...