Subject: Obtaining a host name?
To: None <firstname.lastname@example.org>
From: Jan Danielsson <email@example.com>
Date: 08/14/2005 17:02:44
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
Content-Type: text/plain; charset=ISO-8859-1
My universities student network (broadband at home) requires us to
login before we get access to Internet. To automate the login procedure,
I have written a python script which logs in during boot. I wanted the
script to validate its dhcp-assigned ip against that which is printed in
the login page. (Don't ask.. I guess you can say it was for the hell of
it). I'm kind of glad I did, because I ran into something which made me
This works on my Windows laptop, and on a friends Linux box:
>>> import socket
>>> print socket.gethostbyaddr(socket.gethostname())
It will print my ip address - the one I was given assigned by the dhcp.
However, when I run it on my NetBSD-system, it says:
socket.gaierror: (7, 'No address associated with hostname')
Now, when I connect to some servers with my Windows system, the
server will reply "Hello REGULUS3.student.uu.se", or something like
that. I haven't set that "REGULUS"-variable anywhere, so I assume that
it is sent to me by the dhcp server(?). Now, my NetBSD system doesn't
seem to do that, and what's more: I have set my own hostname in rc.conf.
I assume that is why it fails on NetBSD, gethostname() isn't
returning a "proper" name?
Is there any way to fix so that gethostname() will return that dhcp
assigned name in NetBSD?
Thankful for any pointers.
Te audire no possum. Musa sapientum fixa est in aure.
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)
-----END PGP SIGNATURE-----