Re: Temporarily setting DNS servers
Re: Temporarily setting DNS servers
- Subject: Re: Temporarily setting DNS servers
- From: Allan Nathanson <email@hidden>
- Date: Fri, 23 Apr 2004 14:15:19 -0400
On Apr 23, 2004, at 1:43 PM, Frederik Seiffert wrote:
Quinn wrote:
At 10:59 +0200 23/4/04, Frederik Seiffert wrote:
I want to override DNS settings during the presence of a VPN
connection, i.e. setting new DNS servers (which are usually in the
remote network behind the VPN) when the connection is established
and setting them back to the old values when the connection is
disconnected.
You probably should be doing this using the SCF dynamic store. The
key you're looking for is:
State:/Network/Global/DNS
I already tried this but it didn't seem to work. I used scutil to
change the key like this:
$ sudo scutil
> open
> get State:/Network/Global/DNS
> d.show
<dictionary> {
ServerAddresses : <array> {
0 : 192.168.1.1
}
SearchDomains : <array> {
0 : localdomain.lan
}
}
> d.add SearchDomains * localdomain.lan anotherlocaldomain.lan
> set State:/Network/Global/DNS
> quit
However, after this, /etc/resolv.conf was still the same (unlike when
changing the Setup:/Network/Service/<current set>/DNS key) and
resolving a server from anotherlocalnetwork.lan didn't work. I also
tried sending a HUP to configd and lookupd, but no luck.
Anything else I need to do in order to get a changed setting active?
Thanks,
Frederik
The dictionary associated with the State:/Network/Global/DNS dynamic
store key contains what the DNS configuration HAS BEEN SET TO and is
not the way to change the configuration. What you really want to do is
have your VPN code create a set of
State:/Network/Service/<service-id>/{IPv4,DNS,...} keys which reflect
the configuration associated with the VPN link. If there are matching
"Setup:..." keys then you can have the order the VPN service to the top
of the list and the default route, DNS settings, and proxy
configuration will follow your link when it's active. If your VPN
service is not first in the service order then you can add an
OverridePrimary key to the State:/Network/Service/<service-id>/IPv4
dictionary which will promote your service to the top of the list.
- Allan
p.s. configd, and all of the configuration plugins, ignore SIGHUP
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.