udhcp and dnsmasq info
Hello,
Does anybody know where I can find some info about udhcpc and dnsmasq functionality on maemo (N900), especially the part about how udhcpc transfers DNS servers obtained to dnsmasq, but any info about how these 2 work together would be appreciated. Thanks. |
Re: udhcp and dnsmasq info
udhcpc does the requesting of IP address leases (I think you figured this part out), and dnsmasq takes care of name resolution.
As for how they work together: dnsmasq settings look for a resolv.conf file in a number of places (see /etc/dnsmasq.conf). if any of those files contains a valid name server, it gets used. if you look in /etc/udhcpc/default.bound you will notice that udhcpc updates /var/run/resolv.conf once a successful IP assignment has taken place. dnsmasq dynamically loads the resolv.conf files, so no restart or reload command is needed. That means as soon as udhcpc has chosen a nameserver, it is immediately available for use :) Hope this helps Any specific reason for asking? |
Re: udhcp and dnsmasq info
Hello sicelo,
Thanks for your response. As I see it udhcpc doesn't directly update /var/run/resolv.conf, as in /etc/dnsmasq.conf there are multiple entries, one for each interface (/var/run.resolv.conf.wlan, /var/run.resolv.conf.gprs, /var/run.resolv.conf.lo and /var/run.resolv.conf.ppp0), and /var/run.resolv.conf is never created (at least when I was looking there). Each file (/var/run/resolv.conf.$interface) is created when connecting to that specific interface and contains the DNS server(s). Now after digging a little more I've seen that there is a file /etc/udhcpc/libicd_network_ipv4.script that execute run-parts -a "$1" /etc/maemo-dhcp.d. In /etc/maemo-dhcp.d/ there is only one file called 50_ipv4_network_setup which seem to be the one to create /var/run/resolv.conf.$interface. What I don't know is what calls the /etc/udhcpc/libicd_network_ipv4.script file in first place. Any ideas? Quote:
The scripts I've put in place seem to work and overall I'm satisfied with them but I feel like it could be better integrated if I could just call the scripts that udhcpc already calls with specific parameters to reach the same goal instead of using my own (maybe not so well written) scripts (at least for the ip and dns servers procurement). Now what I look to achieve is better integrate the openvpn ip and dns servers request with the default udhcpc and dnsmasq way of working. The script I'm calling is /etc/openvpn/maemo-update-resolvconf which seem not to respect dnsmasq way on the N900 as it adds the dns server(s) obtained in /etc/resolv.conf (in which only the localhost ip should be) as this way dnsmasq is bypassed and the queries go directly to the upstream dns servers obtained without going through dnsmasq. Hope the explaining was not to bad. |
Re: udhcp and dnsmasq info
Yes I was aware of the *.iface files. However, I do have /var/run/resolv.conf on my N900 ... which is populated by udhcpc when i connect to my work Wi-Fi (WPA-Enterprise .. where Maemo's wlancond fails)
In any case, dnsmasq looks in all /var/run/resolv.conf.* That libicd script is probably called by icd2 when the connection has been successfully established ... i don't believe you will get anywhere with icd2 as it's closed-source (or i'm wrong?). icd2 is responsible for the network connections you select on the connection list (where your vpn will not be) You can see the foregoing with 'ps ax | grep udhcpc' ... and that script is used as the config file ... nothing special involved there can you not just call udhcpc yourself after your vpn connection has been established? that's what i do with wpa_supplicant for my scenario above Code:
udhcpc -h N900 -i wlan0 |
Re: udhcp and dnsmasq info
Quote:
Quote:
Thanks for the clarifications. |
Re: udhcp and dnsmasq info
After some trials and trying to make things work I realized why /etc/openvpn/maemo-update-resolvconf bypasses dnsmasq and puts the DNS server(s) in /etc/resolv.conf.
What I've tried is to create the file /var/run/resolv.conf.tap0 which contains the DNS server of the remote network. Upon creation (from script), dnsmasq sees it has been created and uses the nameserver[1]. Afterwards it seems to query only that server for every request[2]. When disconnecting from the vpn, /var/run/resolv.conf.tap0 is deleted and dnsmasq is aware of it, but still tries to contact the vpn DNS server[3], which is obviously not reachable anymore. So DNS is broken and I can't connect to anywhere by name (it works if I specify directly the ip). The problem seems to be that when dnsmasq becomes aware of a new /var/run/resolv.con.$interface file, it doesn't care anymore about the other one(s). In my case when /var/run/resolv.conf.tap0 is taken into account, /var/run/resolv.conf.gprs becomes like non existent for dnsmasq. So the question is how to make dnsmasq aware of this file again. From the file /var/maemo-dhcp.d/50_ipv4_network_setup I can see that the command kill -SIGHUP `pidof dnsmasq` is used to "reload" dnsmasq, so I used the same command in my script but it doesn't seem to force dnsmasq to check the resolv-files (it only reloads /etc/hosts). I could force restart dnsmasq but I would rather not to if I just could make it aware of the /var/run/resolv.conf.gprs file once /var/run/resolv.conf.tap0 is deleted. [1] Code:
reading /var/run/resolv.conf.tap0 Code:
query[A] domain.com from 127.0.0.1 Code:
failed to access /var/run/resolv.conf.tap0: No such file or directory |
Re: udhcp and dnsmasq info
Quote:
In genwall I restarting dnsmasq with following code: Code:
stop dnsmasq && start dnsmasq |
Re: udhcp and dnsmasq info
Quote:
I start to think that I have another Maemo version than you and sicelo, as you say you have more than one instance of dnsmasq and he says he has already seen a /var/run/resolv.conf file where I never had. Code:
~ $ ps -ef | grep dnsmasq Quote:
Code:
~ $ stop Code:
~ $ /etc/init.d/dnsmasq stop |
Re: udhcp and dnsmasq info
you have the same dnsmasq as all of us .. you're just using it differently from us ...
and yes, there is no /etc/init.d/dnsmasq ... on N900, dnsmasq is managed by upstart, so its start/stop script is in /etc/event.d/ you should just restart dnsmasq when changing your connections ... it's going to be hard to say how Maemo does it, because as mentioned before, icd2 is closed and not reverse-engineered yet (afaik). i don't even know what cleans out the resolv.conf.* files from that directory when the interfaces go down maybe Nokia's dnsmasq was patched? you would have to look in the source the dnsmasq man page says dnsmasq will only reload the resolv.conf.* files if the '--no-poll' argument is included, which is not the case on maemo. this is by dnsmasq design, http://lists.thekelleys.org.uk/piper...q4/000002.html so simplest way - restart dnsmasq. works :) |
Re: udhcp and dnsmasq info
Quote:
|
All times are GMT. The time now is 04:53. |
vBulletin® Version 3.8.8