First, changing the NS IPs in resolv.conf might help your machine think that it's IP address maps to your FQDN but it doesn't help anyone else. The change in dynamic dns will take a few seconds to take effect. I realize though that for things like apache it's helpful/necessary to have the FQDN-dynamic IP working first. It should work (though not necessarily 100% reliably) for you to just have the dynamic dns update occur as soon as you get your DHCP address. I'm assuming you've found this not to be the case.
So, I'll tell you what I do (I also have a host with a cable modem-dispensed dynamic IP that I resolve to my own domain name). I just update /etc/hosts when I get my IP address. I use dhcp-client rather than pump. Actually pump may have the capability that dhcp-client does but I'm not aware of it. With dhcp-client the script /etc/dhclient-script is run to handle events (like getting a new IP). I use a python script I wrote which will find the correct line and update /etc/hosts. It's robust to comments and the position of the hostname. I've hardcoded my hostname in the script so you'll need to update it. Then you just need to edit /etc/dhclient-script and put the call to this script in the right place. Look for the part: if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then ifconfig $interface inet $new_ip_address $new_subnet_arg \ $new_broadcast_arg and after the ifconfig line add: /usr/local/bin/update-ip $new_ip_address (assuming you put the script into /usr/local/bin). And that's all there is to it! Easy huh? Daniel Freedman wrote: > Hi, > > I'm having some difficulties with my Debian 2.2 box using a DHCP-provided > IP address (with cable modem) and dynamic DNS. (And apologies upfront for > the length of this email.) Here's the background: > > I've had the system working for awhile now with DHCP by itself. > Recently, I've been obtaining a dynamic DNS address through dyndns.org > (their nameservers are even collocated here in Ithaca with me!), which > also has always worked fine; however, this dyndns.org address was a > subdomain of dyndns.org, and, since I wasn't receiving mail (i use this, > my school account, for email) or running a webserver, I didn't care that > the machine didn't have a fully qualified domain name for my own SLD. > > Now, however, I've started using easydns.com which allows one to resolve > personal SLD's (that we've registered with ICANN or CORE) with dynamic > dns, and I'd like my machine to be able to recognize it's full domain > name. If I had a static IP, this would probably be easy and I could just > place the ip address and FQDN in the /etc/hosts. However, the way I have > it currently configured (which isn't resolving the FQDN, of course), is to > only place the loopback address (as well as the names and addresses in > 192.168.xxx.xxx for my other home machines) in this file. I then obtain > my current IP address fron DHCP by having RoadRunner's nameservers in my > resolv.conf file. The problem is that I'm not sure where to place the > nameservers for easyDNS.com which actually associate the dynamic IP > address from RoadRunner with my registered domain name. I've tried > replacing the RR ns ip's in resolv.conf with the ns ip's for easydns.com, > but upon reboot, the resolv.conf file is rewritten with the original RR ns > ip's and I still don't have my domainname associated with my dynamic ip. > > I've also tried to fully qualify the domain name in hostname (rather than > just putting the machine name), but that ends up breaking the > configuration (pump --status won't work and other network tests end up > killing the connection). In thinking about things, I'm considering > that the answer might be in changing my routing tables such that the > default gateway isn't the roadrunner domain, but my knowledge is running > precariously thin here. > > I've looked at a bunch of linuxdoc howto's and through this list's > archives, but I don't seem to be getting anywhere, and it's fully possibly > I'm making some stupid mistakes :) Suggestions and pointers would be most > appreciated. I've also appended some of my config files to this message > to help with diagnosing my problem. > > Thanks so very much. > > Take care, > > Daniel > > -------- > > [EMAIL PROTECTED] /etc]# cat resolv.conf > search twcny.rr.com rr.com > nameserver 24.92.226.12 > nameserver 24.92.226.173 > nameserver 24.92.226.174 > [EMAIL PROTECTED] /etc]# cat hostname > osprey > [EMAIL PROTECTED] /etc]# cat host.conf > order hosts,bind > multi on > [EMAIL PROTECTED] /etc]# cat hosts > 127.0.0.1 localhost.localdomain localhost > 192.168.0.1 osprey > 192.168.0.2 warthog > 192.168.0.3 tomcat > [EMAIL PROTECTED] /etc]# ls -l default/pump > -rw-r--r-- 1 root root 0 Jul 5 13:49 default/pump > [EMAIL PROTECTED] /etc/network]# cat interfaces > # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) > > # The loopback interface > iface lo inet loopback > > # The first network card - this entry was created during the Debian > installation > # 3c509 card used to interconnect internal network with DHCP server > iface eth0 inet dhcp > > # The second network card (tulip) to communicate with internal network > iface eth1 inet static > address 192.168.0.1 > netmask 255.255.255.0 > > [EMAIL PROTECTED] /etc]# /sbin/ifconfig > eth0 Link encap:Ethernet HWaddr 00:A0:24:11:61:59 > inet addr:24.24.20.16 Bcast:24.24.21.255 Mask:255.255.254.0 > UP BROADCAST RUNNING MTU:1500 Metric:1 > RX packets:22990 errors:0 dropped:0 overruns:0 frame:0 > TX packets:17845 errors:0 dropped:0 overruns:0 carrier:0 > collisions:37 txqueuelen:100 > Interrupt:5 Base address:0x300 > > eth1 Link encap:Ethernet HWaddr 00:A0:CC:E2:B5:29 > inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0 > UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 > RX packets:19367 errors:0 dropped:0 overruns:0 frame:0 > TX packets:14105 errors:0 dropped:0 overruns:0 carrier:0 > collisions:0 txqueuelen:100 > Interrupt:11 Base address:0x1000 > > lo Link encap:Local Loopback > inet addr:127.0.0.1 Mask:255.0.0.0 > UP LOOPBACK RUNNING MTU:3924 Metric:1 > RX packets:0 errors:0 dropped:0 overruns:0 frame:0 > TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 > collisions:0 txqueuelen:0 > [EMAIL PROTECTED] /etc]# route > Kernel IP routing table > Destination Gateway Genmask Flags Metric Ref Use > Iface > 192.168.0.0 * 255.255.255.0 U 0 0 0 > eth1 > 24.24.20.0 * 255.255.254.0 U 0 0 0 > eth0 > default ith2-a01.twcny. 0.0.0.0 UG 0 0 0 > eth0 > [EMAIL PROTECTED] /etc]# > > -- > Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] < /dev/null -- Jens B. Jorgensen [EMAIL PROTECTED]
#!/usr/bin/python import os, tempfile, string, re, sys # this is the hostname we're going to change the IP address # for hostname = 'jenslaptop' usage = sys.argv[0] + ' <ip address>' # check the args first ip_matcher = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') if len(sys.argv) < 2 or not ip_matcher.match(sys.argv[1]) : sys.stderr.write(usage + '\n') sys.exit(-1) ip_address = sys.argv[1] # first we update /etc/hosts # to do this we need to find the entry which matches the hostname # we create a temporary file we write each line into and mv the file # into place when we're done hosts = open('/etc/hosts', 'rt') tempfile.tempdir = '/etc' new_hosts_fname = tempfile.mktemp() new_hosts = open(new_hosts_fname, 'wt') # construct our hostname-matching regex # we can get away with matching whitespace on both sides because # each line read in retains the newline # so prepare our re match object matcher = re.compile('\s(' + hostname + ')\s', re.IGNORECASE) while 1 : l = hosts.readline() # end of file? if len(l) == 0 : break # we need to make a copy of l with any comment trimmed off idx = string.find(l, '#') if idx == -1 : l_trimmed = l else : l_trimmed = l[0:idx] # now try to match the hostname m = matcher.search(l_trimmed) if m : # got a match, now find the ip ip_m = ip_matcher.match(l_trimmed) if ip_m : # ok, update the original line l = ip_address + l[ip_m.end():] # now write out the line to the new file new_hosts.write(l) hosts.close() new_hosts.close() # now put the new file in place os.rename(new_hosts_fname, '/etc/hosts') sys.exit(0)