Log in

23 March 2015 @ 09:43 pm
setting dns servers on Ubuntu via NetworkManager/dnsmasq  
для пущей индексации пускай будет на английском.
While switching (to be honest - trying to switch, things not going smooth at all, like, while i'm writing this Ubuntu experienced internal error somewhere in kernel related to pulsadio, I guess this is echo of disabling audio on virtual machine properties of VirtualBox, but who knows ;) i've found that:

  1. openvpn plugin for Network Manager usually works (though requiring several time to click on connection) I can connect to vpn, but can't disconnect.

  2. after switching from Unity to LXDE (both are not God blessed if u care) connection icon in system tray (or how linuxoids name it) doesn't show anything related to openvpn.

  3. using openvpn under Network Manager/Unity I was forced to switch default route via remote gateway, while that gateway didn't insist on such configuration.

So I decided to try to start it inside tmux session - works like a charm [for now]. The only thing which occasionally has become broken [who said "what did u expect from Linups on desktop?!"] was the dns servers driven by remote gateway - as it wasn't managed by NetworkManager, openvpn wasn't propogating recieved dns list into my system, surprise, surprise.
To help eliminate this shitty shit, one can use cli interface to dnsmasq via dbus, which still looks and feels weird, but at least works for static connections (i.e. when u know dns servers and them not gonna change). So my snippet is below:

echo "changing dns for internal zones"
dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager.dnsmasq /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetDomainServers array:string:'/localsuffix/',"",""

/localsuffix/ - is zonename/dns_server_ip_for_that_zone , so you can specify that requests for say, srv01.mycompany.localsuffix will go through that server.
"","" - the rest, catch all dns servers, like nearest to you, office ones.

the whole vpn startup script looks like:
cd /home/coolcold && tmux new-session -A -s ovpn 'sudo openvpn --route-up /home/coolcold/changedsnvpn.sh --script-security 2 --config user.ovpn'

Happy Ubunting!