Find the answer to your Linux question:
Results 1 to 2 of 2
I have dnsmasq running on my localhost and it works fine with dhcpcd. I made it work by prepending nameserver to /etc/resolv.conf by creating the /etc/resolv.conf.head file: Code: echo "nameserver ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2007
    Posts
    65

    Cool Can't get dhclient to use local DNS


    I have dnsmasq running on my localhost and it works fine with dhcpcd. I made it work by prepending nameserver to /etc/resolv.conf by creating the
    /etc/resolv.conf.head file:
    Code:
    echo "nameserver 127.0.0.1" > /etc/resolv.conf.head
    However, I want to use dhclient instead but I can't get it to work. The dnsmasq is just being ignored even if I add "prepend domain-name-servers 127.0.0.1;" to /etc/dhclient.conf

    Code:
    prepend domain-name-servers 127.0.0.1;
    send host-name = pick-first-value(gethostname(), "ISC-dhclient");
    send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
    send dhcp-lease-time 3600;
    supersede domain-search "fugue.com", "home.vix.com";
    request subnet-mask, broadcast-address, time-offset, routers, domain-name, host-name;
    #request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, host-name;
    require subnet-mask, domain-name-servers;
    timeout 60;
    retry 60;
    reboot 10;
    select-timeout 5;
    initial-interval 2;
    script "/etc/dhclient-script";
    media "-link0 -link1 -link2", "link0 link1";
    reject 192.33.137.209;
    
    alias {
      interface "ep0";
      fixed-address 192.5.5.213;
      option subnet-mask 255.255.255.255;
    }
    
    lease {
      interface "ep0";
      fixed-address 192.33.137.200;
      medium "link0 link1";
      option host-name "andare.swiftmedia.com";
      option subnet-mask 255.255.255.0;
      option broadcast-address 192.33.137.255;
      option routers 192.33.137.250;
      option domain-name-servers 127.0.0.1;
      renew 2 2000/1/12 00:00:01;
      rebind 2 2000/1/12 00:00:01;
      expire 2 2000/1/12 00:00:01;
    }
    Can anyone see where's the issue?

  2. #2
    Just Joined!
    Join Date
    Jul 2007
    Posts
    1
    I had similar problem a few time ago. I can't remember exactly how I solved it, but it was using hooks. Take a look at "man dhclient-scripts" .

    HOOKS
    When it starts, the client script first defines a shell function, make_resolv_conf , which is later used to create the /etc/resolv.conf file. To override the default behav‐
    iour, redefine this function in the enter hook script.

    On after defining the make_resolv_conf function, the client script checks for the presence of an executable /etc/dhcp/dhclient-enter-hooks script, and if present, it invokes the
    script inline, using the Bourne shell . command. The entire environment documented under OPERATION is available to this script, which may modify the environment if needed to
    change the behaviour of the script. If an error occurs during the execution of the script, it can set the exit_status variable to a nonzero value, and /sbin/dhclient-script
    will exit with that error code immediately after the client script exits.

    After all processing has completed, /sbin/dhclient-script checks for the presence of an executable /etc/dhcp/dhclient-exit-hooks script, which if present is invoked using the
    . command. The exit status of dhclient-script will be passed to dhclient-exit-hooks in the exit_status shell variable, and will always be zero if the script succeeded at the
    task for which it was invoked. The rest of the environment as described previously for dhclient-enter-hooks is also present. The /etc/dhcp/dhclient-exit-hooks script can
    modify the valid of exit_status to change the exit status of dhclient-script.

    Immediately after dhclient brings an interface UP with a new IP address, subnet mask, and routes, in the REBOOT/BOUND states, it will check for the existence of an executable
    /etc/dhcp/dhclient-up-hooks script, and source it if found. This script can handle DHCP options in the environment that are not handled by default. A per-interface.
    /etc/dhcp/dhclient-${IF}-up-hooks script will override the generic script and be sourced when interface $IF has been brought up.

    Immediately before dhclient brings an interface DOWN, removing its IP address, subnet mask, and routes, in the STOP/RELEASE states, it will check for the existence of an exe‐
    cutable /etc/dhcp/dhclient-down-hooks script, and source it if found. This script can handle DHCP options in the environment that are not handled by default. A per-interface
    /etc/dhcp/dhclient-${IF}-down-hooks script will override the generic script and be sourced when interface $IF is about to be brought down.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •