drwindsorhttps://nullcore.wordpress.com
Fri, 10 Mar 2017 11:10:53 +0000enhourly1http://wordpress.com/https://secure.gravatar.com/blavatar/852806268c2c59ee85b4ef1ed53c2018?s=96&d=https%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.pngdrwindsorhttps://nullcore.wordpress.com
The Next Installment of The Dark Towerhttps://nullcore.wordpress.com/2011/12/14/the-next-installment-of-the-dark-tower/
https://nullcore.wordpress.com/2011/12/14/the-next-installment-of-the-dark-tower/#respondWed, 14 Dec 2011 15:43:22 +0000http://nullcore.wordpress.com/?p=38]]>I just finished reading the last book in The Dark Tower, a 7-volume series by Stephen King. It’s replaced The Lord of the Rings’ position as my favorite story. Yes, my favorite story. Not my favorite book (or series of books), but my favorite story: my favorite sequence of fictional events, of any length. The Dark Tower’s story is told in such a masterful way that even before reaching the end of the series, I enjoyed its story more than that of any other. I’d say that at the end of The Wastelands (about halfway through the series), during the battle of riddles with Blaine the Mono, is when I reached this conclusion.

The Dark Tower, an epic fantasy tale whose protagonists are a Gunslinger, a recovering heroin addict, a young boy and a black woman who is missing both of her legs, simply rocks. Its villains are even more interesting. There’s nothing else like it.

That being said, I’m at a loss as to what I’m going to read now. I thought the experience of The Dark Tower was finished, or, in the words of Stephen King, that I’d reached “the clearing at the end of the path” with respect to The Dark Tower. I’m eternally grateful to announce that I’m *not* in fact finished with this story, as there is yet another installment forthcoming. That’s right, an eighth book.

In the interest of not making this post a spoiler, I won’t reveal too many details here about the plot of this next installment, only that it will take place somewhere in between the series’ third and fourth books. It’s already been written and is expected to be published in 2012.

The announcement of this next book was made by Stephen King on his website and can be found here.

]]>https://nullcore.wordpress.com/2011/12/14/the-next-installment-of-the-dark-tower/feed/0nullc0reavahi and DNShttps://nullcore.wordpress.com/2011/12/09/avahi-and-dns/
https://nullcore.wordpress.com/2011/12/09/avahi-and-dns/#respondFri, 09 Dec 2011 22:51:29 +0000http://nullcore.wordpress.com/?p=13]]>Related to my last posting, sudo was lagging when attempting to resolve hostnames unique to local network (my work’s domain). Anyway, after strace-ing, I found that sudo was timing-out while using avahi to resolve these local names.

While implementing a naming scheme (I’m going with the not very creative name-after-types-of-alcohol naming scheme) for machines at work, I wanted bash prompt to reflect my machine’s current hostname as distributed by DHCP. I’m running Ubuntu 11.10 on my laptop, a Dell Inspiron N5110.

By default, Linux systems determine their hostname by using the hostname command. hostname, in turn, uses uname(2) to determine the hostname.

Ubuntu 11.10 uses NetworkManager as tool of choice for users to configure network interfaces and NetworkManager seems to be using dhclient as its DHCP client. I’m personally more familiar with dhcpcd, but that’s neither here nor there (or so I thought).

What I wanted to accomplish was simple. I wanted Ubuntu to set my hostname dynamically upon receiving an address from DHCP, so that hostname returned a name that came from DHCP. I know that DHCP has a mechanism by which clients can request a particular hostname, but this is the opposite of what I want. I want DHCP to tell me my hostname, and I want Ubuntu to set it. Here’s how I made that happen.

Background

In the good old days, when I was one of the cool kids drinking the Gentoo kool-aid, I remember dealing with this exact same issue using a switch to dhcpcd. It turns out that it was the -H switch. From man dhcpcd:

-H
Forces dhcpcd to set hostname of the host to the hostname option supplied
by DHCP server. By default dhcpcd will NOT set hostname of the host to the
hostname option received from DHCP server.

Great! This is exactly what I want.

Unfortunately, as I mentioned before, NetworkManager doesn’t use dhcpcd. It uses dhclient, provided by the isc-dhcp-client package. The simple functionality that I want can’t be unique to dhcpcd, can it?

Well, it is, sort of. dhclient doesn’t natively support this functionality, but instead offers a hook-based interface in which scripts can be run at certain times in the address-acquisition process. The dhclient-script program provides the framework for this hook-based interface. It looks for hooks in two places: /etc/dhcp/dhclient-enter-hooks.d/ and /etc/dhcp/dhclient-exit-hooks.d/. For our purposes, we want to set our hostname based upon the address acquired from DHCP, so we’ll have to place our script in the latter location, as it should be executed as an “exit” hook.

The Solution

The script itself has fortunately already been written by the Debian folks. Look here for the original article if you are interested, but here is the script, modified slightly to work on Ubuntu 11.10:

Save this script in /etc/dhcp/dhclient-exit-hooks.d/ and your system’s hostname will henceforth be set automatically by dhclient.

Update

Since saving this script, I’ve been noticing that I’d receive strange hostnames from DHCP. It turns out that the reason for this was virtual machines requesting an IP address. To fix this, we need to add some sort of specification to the hostname script that only updates our hostname if the response from DHCP is intended for a real (not virtual) interface.

To support this kind of logic, dhclient-script provides the $interface variable. From man dhclient-script:

The interface name is passed in $interface, and the media type is passed in $medium.