Networking Forums

Networking Forums > Computer Networking > Linux Networking > Change resolv.conf for one particular DHCP server

Reply
Thread Tools Display Modes

Change resolv.conf for one particular DHCP server

 
 
Stefan Monnier
Guest
Posts: n/a

 
      08-21-2007, 06:54 PM

My laptop is configured in the usual way to get his IP and DNS servers
by DHCP. But there's a cybercafé to which I like to go who's wireless
router is configured to return as DNS server some overloaded servers, even
though the AP is actually running a caching DNS proxy, so I sometimes
manually override the DHCP info by adding 192.168.0.1 in /etc/resolv.conf
just to speed up my connections.

Now, doing it manually is a pain, so I was wondering if anybody has an idea
how I could make this change automatically.

I'm currently using wpa_supplicant + dhclient3 + resolvconf under Debian
testing if that matters.

I'm currently using an ugly hack:

#!/bin/sh

resolvconf=/etc/resolvconf/run/resolv.conf
trigger_re="nameserver 4\\.2\\.2\\.2"
extraline="nameserver 192.168.0.1"

(rm "$resolvconf";
sed "/$trigger_re/i# Next line added by $0\\n$extraline" \
>"$resolvconf" ) <"$resolvconf"


in /etc/resolconf/update-libc.d and was wondering if there's
a cleaner solution.


Stefan
 
Reply With Quote
 
 
 
 
M4teK
Guest
Posts: n/a

 
      08-22-2007, 07:58 AM
On 21 Sie, 20:54, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> My laptop is configured in the usual way to get his IP and DNS servers
> by DHCP. But there's a cybercafé to which I like to go who's wireless
> router is configured to return as DNS server some overloaded servers, even
> though the AP is actually running a caching DNS proxy, so I sometimes
> manually override the DHCP info by adding 192.168.0.1 in /etc/resolv.conf
> just to speed up my connections.
>
> Now, doing it manually is a pain, so I was wondering if anybody has an idea
> how I could make this change automatically.
>
> I'm currently using wpa_supplicant + dhclient3 + resolvconf under Debian
> testing if that matters.
>
> I'm currently using an ugly hack:
>
> #!/bin/sh
>
> resolvconf=/etc/resolvconf/run/resolv.conf
> trigger_re="nameserver 4\\.2\\.2\\.2"
> extraline="nameserver 192.168.0.1"
>
> (rm "$resolvconf";
> sed "/$trigger_re/i# Next line added by $0\\n$extraline" \
> >"$resolvconf" ) <"$resolvconf"

>
> in /etc/resolconf/update-libc.d and was wondering if there's
> a cleaner solution.
>
> Stefan


In file /etc/dhclient.conf put

lease
{
interface "wlan0";
option domain-name-servers 153.19.250.100;
}

where 'wlan0' is your wireless interface name.

M4teK

 
Reply With Quote
 
Stefan Monnier
Guest
Posts: n/a

 
      08-22-2007, 05:54 PM
>> My laptop is configured in the usual way to get his IP and DNS servers
>> by DHCP. But there's a cybercafé to which I like to go who's wireless
>> router is configured to return as DNS server some overloaded servers, even
>> though the AP is actually running a caching DNS proxy, so I sometimes
>> manually override the DHCP info by adding 192.168.0.1 in /etc/resolv.conf
>> just to speed up my connections.
>>
>> Now, doing it manually is a pain, so I was wondering if anybody has an idea
>> how I could make this change automatically.
>>
>> I'm currently using wpa_supplicant + dhclient3 + resolvconf under Debian
>> testing if that matters.
>>
>> I'm currently using an ugly hack:
>>
>> #!/bin/sh
>>
>> resolvconf=/etc/resolvconf/run/resolv.conf
>> trigger_re="nameserver 4\\.2\\.2\\.2"
>> extraline="nameserver 192.168.0.1"
>>
>> (rm "$resolvconf";
>> sed "/$trigger_re/i# Next line added by $0\\n$extraline" \
>> >"$resolvconf" ) <"$resolvconf"

>>
>> in /etc/resolconf/update-libc.d and was wondering if there's
>> a cleaner solution.
>>
>> Stefan


> In file /etc/dhclient.conf put


> lease
> {
> interface "wlan0";
> option domain-name-servers 153.19.250.100;
> }


> where 'wlan0' is your wireless interface name.


But that will be used everywhere, right? I only want to change the
resolv.conf when I use the machine at that one cybercafé. The 192.168.0.1
address I need to use there doesn't even work in most other places (at
home and at work, at least).


Stefan
 
Reply With Quote
 
M4teK
Guest
Posts: n/a

 
      08-24-2007, 10:52 AM
On 22 Sie, 19:54, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> >> My laptop is configured in the usual way to get his IP and DNS servers
> >> by DHCP. But there's a cybercafé to which I like to go who's wireless
> >> router is configured to return as DNS server some overloaded servers, even
> >> though the AP is actually running a caching DNS proxy, so I sometimes
> >> manually override the DHCP info by adding 192.168.0.1 in /etc/resolv.conf
> >> just to speed up my connections.

>
> >> Now, doing it manually is a pain, so I was wondering if anybody has anidea
> >> how I could make this change automatically.

>
> >> I'm currently using wpa_supplicant + dhclient3 + resolvconf under Debian
> >> testing if that matters.

>
> >> I'm currently using an ugly hack:

>
> >> #!/bin/sh

>
> >> resolvconf=/etc/resolvconf/run/resolv.conf
> >> trigger_re="nameserver 4\\.2\\.2\\.2"
> >> extraline="nameserver 192.168.0.1"

>
> >> (rm "$resolvconf";
> >> sed "/$trigger_re/i# Next line added by $0\\n$extraline" \
> >> >"$resolvconf" ) <"$resolvconf"

>
> >> in /etc/resolconf/update-libc.d and was wondering if there's
> >> a cleaner solution.

>
> >> Stefan

> > In file /etc/dhclient.conf put
> > lease
> > {
> > interface "wlan0";
> > option domain-name-servers 153.19.250.100;
> > }
> > where 'wlan0' is your wireless interface name.

>
> But that will be used everywhere, right? I only want to change the
> resolv.conf when I use the machine at that one cybercafé. The 192.168.0.1
> address I need to use there doesn't even work in most other places (at
> home and at work, at least).
>
> Stefan



yes, you are right
as far as I know there is no possibility to do conditional changes
via dhclient.conf file, but on every dhcp update there can be some
script started, so check this way

MR

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dhcpd.conf, resolv.conf and the search directive Andy Richardson Linux Networking 4 07-13-2005 08:23 AM
Question on resolv.conf red Linux Networking 2 02-16-2005 10:58 AM
Q: Simple way to pick up resolv.conf info from DHCP to DNS? Sundial Services Linux Networking 2 11-15-2004 01:09 PM
resolv.conf Stephen Speicher Linux Networking 5 12-10-2003 09:00 AM
NIS, DNS and resolv.conf ncrfgs Linux Networking 2 10-02-2003 05:09 PM



1 2 3 4 5 6 7 8 9 10 11