Subject: Re: Obtaining a host name?
To: segv <segv@netctl.net>
From: Jan Danielsson <jan.danielsson@gmail.com>
List: netbsd-users
Date: 08/14/2005 19:16:13
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigCE4F9FA94E041E90ABF67548
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

segv wrote:
>>   That leads me to the question: What is it that XP and Linux are doing
>>to make my python script work? I assume they are placing something like
>>this in /etc/hosts:
> 
> I don't really understand what your script is supposed to do. And things like
> which dhcp/dns servers you're using, etc. If you explain it in more details I
> could give you a more detailed answer...

   Ok, sorry.. As I stated before, I know virtually nothing about
networking, so I don't know how much to assume.

First, the basics:

   I just connect my systems to a socket in the wall, and I get my
address via dhcp. The network doesn't allow protocols such as http and
ftp without first logging in. Whereever I try to point a browser, I get
to the login page. Once I have logged in, I can use http & ftp to reach
the outside world.

   The script I mentioned is just a script to automate the login
process, so I won't have to fire up a web browser. On the logon page, it
displays the users ip address. I want to compare that ip with the one
that has been assigned to be by the dhcp server. Parsing the HTML and
acquiring the ip was easy using HTMLParser in Python, so that's not a
problem. The problem is acquiring the ip address (in a portable way).
The script I posted eariler works on my XP system and a friends Linux
system, but it did not work on my NetBSD system.

   The problem is not getting the host name, but rather resolving it
into an ip address. That's the call that fails on NetBSD.

   As suggested in netbsd-users, I tried removing the "hostname" in
rc.conf, and restarted. Then, when I typed "hostname" it returned an
empty string: Ergo, the dhcp isn't handing out host names.

   Now, this should mean that my XP and the Linux system aren't getting
host names from the dhcp-server either, yet, the python script does work
on those systems.

   I figure that means that XP and the Linux system stuff the host name
and the systems assigned ip into some file somewhere (/etc/hosts or
resolve.conf:ish file (I'm not sure what resolve.conf actually does)).
So I thought I would make my NetBSD system do the same. But I'm unsure
of how I would do that.

   I have, through reading some man-pages, found that I can create a
file called /etc/dhclient-enter-hooks which will be called whenever the
dhcpclient has done something.

I guess what I want to do, is to add:

<my newly assigned ip> <my hostname>

to /etc/hosts

..by writing a /etc/dhclient-enter-hooks script.

   I'm guessing that this will allow the python script to run and report
back my ip, just as it does on XP or the Linux system.

What I'm wondering is:

1) Will this work? Am I missing something obvious?

2) Is there an "official" way to do all of this, that I am unaware of?


-- 
Kind Regards,
Jan Danielsson
Te audire no possum. Musa sapientum fixa est in aure.

--------------enigCE4F9FA94E041E90ABF67548
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)

iD8DBQFC/3xi8wBCTJQ8HEIRAtKgAJ9GscQPQ+LkTD8ssDAvStwlI8eCvACeP4VH
a1Y9EZI+6x+UpfbMOx+MI54=
=Szjw
-----END PGP SIGNATURE-----

--------------enigCE4F9FA94E041E90ABF67548--