On 3/28/06, Peter Bako <[EMAIL PROTECTED]> wrote:
> Is there any way to get the DHCPD.CONF file be set to use the DNS
> information from the resolv.conf file?
>
> Specifically I have a case where my firewall's outside interface gets its IP
> address via DHCP from the ISP. When I initially setup the firewall I put
> their DNS IP numbers into my conf file and have been working without any
> issues for quite a while now. However they just sent out a letter to all of
> their customers asking them to make sure they have their system setup to use
> the DNS numbers that are pushed down via DHCP or possibly lose connectivity
> due to changes in their DNS server assignments. I supposed I could wait
> until the old DNS servers no longer respond and then update my DHCPD.CONF
> file with whatever I find in the resolv.conf file, but I would prefer to
> make this a bit more automated...
>
Well you could always script it:
#dhcpmeep.py
import sys, os
def getservers():
for line in open("/etc/resolv.conf"):
if line.startswith("nameserver"):
return line.replace("nameserver","").split().sort()
oldservers = getservers()
while 1: #until the servers change
newservers = getservers()
if newservers != oldservers:
open("/etc/dhcpd.conf","+").write("option domain-name-servers "
+ ", ".join(newservers))
os.system("pkill dhcpd")
os.system("dhcpd")
break
sys.remove("dhcpmeep.py")
So just start it running and it'll push changes over to dhcpd when
they occur, and then delete itself so you don't even need to clean up
after it. Of course, it does this in a very bad (and untested) way,
but you get the idea.
-Nick