Re: wget not resolving domain names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 06, 2005 at 09:48:06PM +1030, Tim wrote:
> Tim:
> 
> >> I think that the usefulness of Paul's example is that you can change
> >> the machine acting as "myserver" with one record change (the A record
> >> for "myserver".  Alternatively, if you made all the next three
> >> records "A" records with the same IP address, you'd need to change
> >> all of them.
> 
> Derek Martin:
> 
> > Oh, come now...
> > 
> > If this is genuinely a problem for you, then you need to spend some
> > time learning how to use your favorite editor, or find a better one...
> 
> Re-instating my next paragraph:
> 
> "Probably not a real pain for three servers, but if you'd faced an
> annoyance of suddenly having to replace 10, or more, server
> addresses in one go, you'd probably appreciate being able to fix
> things with just one modification to one record."

Sigh...

I read this the first time, and it simply isn't true.  That's why I
left it out.  It's irrelevant, because this "annoyance" you speak of
is easily eluded... it's a red herring.

> It's clear that you're just flapping your gums in the breeze for the
> sake of having an argument.

NO.  THIS IS NOT A PROBLEM.

No matter how many servers you're talking about, we're still talking
about changing the CNAMEs or A records associated with one machine (or
rather, one A record and therefore 1 IP address).  THIS CAN ALWAYS BE
DONE QUICKLY AND EASILY, if you know how to use the tools at your
disposal, whether it's 10 or 10,000 records.

> No, it's not something I want to do, but from the theoretical point of
> view, there's a good reason for the technique Paul offered of CNAMEing
> lots of different servers to the one server address:  The simplicity of
> changing the lot, in one go, with just one edit, to a different address,
> should you need to.

And I say it's not a factor at all.

I gave you syntax to do exactly that (change them all with one edit),
assuming they're all in one file.  If the addresses are in different
files, you have a couple of options.  If you have some aversion to
shell scripts, you can load them all into your editor at the same
time, in different buffers, and just repeat the search and replace
operation once per buffer.  Or if that's too much work for you, you
can use a tiny shell script to do it on the command line.  I don't
care if you have 1,000,000 records that all point to the same IP
address.  This just simply IS NOT A PROBLEM.

> There is really no argument to say that it's not easier to just edit the
> one A record to change where all the CNAMEs point to, compared to
> writing a script just to do the same thing.

It takes 5 minutes to write the script, and once it's done you never
need to do it again.   So every time other than the first time, THERE
IS NO DIFFERENCE.  And to save you the trouble of writing the script
the first time, here it is:

-=-=-=-=-
#!/bin/sh
# ip_fixer.sh - change IP of all A records that point to $1
# $1 is the old IP, $2 is the new IP
# 
# This is untested due to lack of any zone files on my machine to test
# them with (and sheer laziness to grab some), though I think it's
# right.  If it is somehow broken, it should be simple to fix with a
# few minutes of testing.
#
# This really should save back-up copies of the originals and use
# mktemp for security, but who cares?  It's just a quick and dirty
# hack to prove a point anyway.
#
TMPFILE=$TMPDIR/mytmpzone
regex=`echo $1 | sed 's/\./\\./'`
for file in *; do
	if grep -q "[^0-9]$regex[^0-9]" "$file"; then
		sed "s/[^0-9]$regex[^0-9]/$2/g" > "$TMPFILE"
		mv "$TMPFILE" "$file"
	fi
done
rm $TMPFILE
-=-=-=-=-=-

There.  9 lines of code plus comments.  The comments took more time to
write than the script itself...  Now you never have an excuse not to
use A records instead of CNAMEs.  Run this script in the directory
where you keep your zone files, and you never have to change them
manually again.  I would argue that this is actually EASIER than
changing just one A record to which many CNAMEs point, because you
don't need to know what file the A record lives in, and you don't have
to load it up in your editor and search for it.  You only need to type
one line:

  ip_fixer.sh <old_IP> <new_IP>

and the whole thing is done.  No editing necessary.  How much easier
could it possibly be?  As an extra added bonus, it will even work for
partial IPs (assuming it works at all), say if you want to change your
subnet from 172.16.7 to 10.1.3.  If you're a little bit clever, it's
easy to modify it to automatically update your zone files' serial
numbers too.  I'll leave that as an exercise.  [Hint: since it's just
a series of decimal digits, you need something to help match on the
serial number in the zone file, so a well-placed comment would be
quite useful (e.g. ; Serial Number.).]  After that, you can even have
it tell named to reload the zone files for you...  Simplicity itself.

Now I admit, this is not as helpful if only SOME of your hostnames
need to change... but CNAMEs won't help you much there, either.
You'll still need to change all the CNAME records that are going to
point to a different machine, and unless you have some clever naming
scheme that you can match on, you're going to need to do that entirely
by hand to make sure you get it right (same as with A records)...  

And don't forget about all the problems we mentioned before that
CNAMEs can potentially cause.  CNAMEs are NOT better, IMO, not in any
way.  They SEEM like a good idea, but their implementation can cause
problems which are not worth the hastle.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D

Attachment: pgpoHQpEOlcJH.pgp
Description: PGP signature


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux