09.05.08

Keep DHCP From Overwriting Search Domains

Posted in Intermediate, Linux at 3:11 pm by Techie

Let’s say you have a bunch of hosts on example.com, such as mercury.example.com, venus.example.com, and jupiter.outerplanets.example.com. You spend a bunch of your time on the command line, so you want to be able to access them with just the short host name, i.e., you want to be able to just type ssh mercury and not worry about the domain.

If you happen to be on the same domain, e.g. on saturn.example.com, this usually works fine. What if you’re not? The usual answer is to edit your /etc/resolv.conf file, and edit your search domains like so:

search example.com outerplanets.example.com

This works great — you can even ssh jupiter and it’ll do the right thing. It will, that is, right until you DHCP up a new IP address, say on another Internet connection. Then it overwrites your search domains, and you have to re-edit the file. What’s a techie to do? Use dhclient.conf, of course!

On hardy, I edited the file /etc/dhcp3/dhclient.conf and added this line:

supersede domain-name "example.com outerplanets.example.com";

Then, I did an sudo /etc/init.d/dhcdbd force-reload to make the dhclient change. However, my connection still had the old network information. To fix that, I just stopped and started my connection like so:

sudo ifconfig eth0 down
sudo ifconfig eth0 up

Voila — my search domains work again, and will work the next time I DHCP up a new IP.

09.04.08

How To Determine Perl Module Versions

Posted in Intermediate, Linux at 12:55 pm by Techie

How do you determine what version of a Perl module you have? If you have one module you want to check, you can call the VERSION parameter of the module. Let’s say you wanted to check the version of Test::Harness you had on your system. Run the following:

$ perl -MTest::Harness -le 'print Test::Harness->VERSION'
2.56
$

Another way:

$ perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Test::Harness
2.56
$

Seems simple enough. But what if we want to check all module versions, versus what was current on CPAN?

$ perl -MCPAN -e 'CPAN::Shell->r'

That’s not foolproof, as some modules don’t have version numbers, but should give you a good idea. It also has the bonus of providing you with information on how out of date you are with CPAN.

Bad Behavior has blocked 280 access attempts in the last 7 days.