LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   DHCP Problems - Script? (https://www.linuxquestions.org/questions/linux-software-2/dhcp-problems-script-232206/)

Kane635 09-18-2004 02:12 PM

DHCP Problems - Script?
 
[kane@localhost kane]$ su
Password:
[root@localhost kane]# cat /etc/resolv.conf
nameserver 192.168.1.1
[root@localhost kane]#
nameserver 64.78.119.1
nameserver 64.78.119.2
search localhost
[root@localhost kane]# vi /etc/resolv.conf
[root@localhost kane]# cat /etc/resolv.conf
nameserver 64.78.119.1
nameserver 64.78.119.2
search localhost
[root@localhost kane]#

Anyway, I don't want toe 192.168.1.1 there. Its my firewall, and the DNS request goes to that first, then the others, making my DNS problem about 15 seconds in timeout. Anyone give me a script to remove the first line of /etc/resolv.conf at startup?

CroMagnon 09-18-2004 02:56 PM

Why make a script to do that when you can just set the DHCP server to give out the right nameservers to begin with?

Anyway, try:
Code:

#!/bin/bash
if grep -q "192\.168\.1\.1" /etc/resolv.conf; then
  sed -e "s/nameserver 192\.168\.1\.1//g" /etc/resolv.conf > /tmp/newresolv
  # If you don't like sed, you could use the next line instead:
  # grep -v "192\.168\.1\.1" /etc/resolv.conf > /tmp/newresolv
  mv /tmp/newresolv /etc/resolv.conf
fi


Kane635 09-18-2004 04:17 PM

Woot!
 
I can't configure the DHCP server to not retreive from my firewall, even though it doesn't serve as a DNS server. =.= I don't know why. + Where do I stick the script to boot on start?

CroMagnon 09-18-2004 04:42 PM

What is in your dhcpd.conf? It shouldn't give out anything you don't tell it to.

As for the script... this might be different on your distribution, but save it wherever you like... if you save it as /etc/network/fixdhcp, edit your /etc/network/interfaces file to look like this:

Code:

iface eth0 inet dhcp
  up /etc/network/fixdhcp

Test it with "ifdown eth0; ifup eth0"


All times are GMT -5. The time now is 10:24 AM.