[Python-bugs-list] [ python-Bugs-615472 ] socket.getfqdn() doesn't on Windows

noreply@sourceforge.net noreply@sourceforge.net
Mon, 30 Sep 2002 05:01:29 -0700


Bugs item #615472, was opened at 2002-09-27 07:32
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=615472&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Robert Olson (olson)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket.getfqdn() doesn't on Windows

Initial Comment:
On windows, socket.getfqdn() doesn't return a fully qualified 
name. Further, it returns the NETBIOS name (I think they call it 
that) of the computer, not a name that's useful for 
networking:

C:\>\Python22\python.exe
Python 
2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import socket
>>> 
socket.getfqdn()
'lorax'

Python 2.2.1 (from 
python.org), Windows 2000.

--bob

----------------------------------------------------------------------

>Comment By: Robert Olson (olson)
Date: 2002-09-30 07:01

Message:
Logged In: YES 
user_id=20112

This is win2k. The "full computer name" doesn't have the full domain; and 
there isn't a primary domain suffix, so that may be what you mean by 
misconfigured. 

However, when I get IP and DNS information via 
DHCP, I would not expect to have to manually configure the computer 
name each time I use the machine in a differnet place (this is what DHCP 
is for). A DNS lookup on my IP address should give me the full information. 
Sigh, I suspect I may be up against a windows limitation perhaps.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-09-30 02:44

Message:
Logged In: YES 
user_id=21627

It works fine for me, on an XP system. What Windows version?

In "computer properties/computer name/Change", what do you
see as "complete computer name"? In "more", what is the
"primary domain suffix"? (I only have a German installation,
so I'm uncertain how this reads in an English installation)
I still suspect your machine is misconfigured.

----------------------------------------------------------------------

Comment By: Robert Olson (olson)
Date: 2002-09-29 18:32

Message:
Logged In: YES 
user_id=20112

Is this what you're looking for?

$ python
Python 2.1.1 (#2, Aug 
23 2001, 10:41:44) 
[GCC 2.95.3-5 (cygwin special)] on 
cygwin
Type "copyright", "credits" or "license" for more 
information.
>>> import socket
>>> 
socket.getfqdn()
'only'
>>> 
socket.gethostname()
'only'
>>> 
socket.gethostbyaddr(socket.gethostname())
('only', [], 
['140.221.10.174', '192.168.153.1', '192.168.43.1'])

(different 
machine & python, same behavior; the one I used before is now on a 
network where it doesn't have a real name).

I've seen this on all the 
Windows machines I've used; it seems like Windows refuses to let the 
DNS-based name come through, if it already thinks it knows the name 
based on the Netbios name of the machine.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-09-29 17:23

Message:
Logged In: YES 
user_id=21627

This is not true; getfqdn returns a fully qualified name
even on Windows. If it doesn't do that on your system, this
reason is different than just being Windows.

Can you please report the outcome of the following calls?

socket.gethostname()
name = _
gethostbyaddr(name)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=615472&group_id=5470