Openvpn client, force DNS server

After more googling, could find the answer - below if it can help someone.

  • install resolvconf which can save and restore the resolv.conf config file
  • add a script to be run by openvpn, in /usr/share/openvpn, named update-resolv-conf. The script determines what should be the new resolv.conf, and how to restore it (see link below)
  • add

these lines

  script-security 2
  up /usr/share/openvpn/update-resolv-conf
  down /usr/share/openvpn/update-resolv-conf

in the openvpn client config file.

Read on this wiki for more information.