[issue10821] gethostbyname(gethostname()) is wrong when IP is changed
Petr Sklenář
report at bugs.python.org
Tue Jan 4 11:18:18 CET 2011
New submission from Petr Sklenář <psklenar at redhat.com>:
version:
tried python 2.6 on rhel55
tried python-2.7-8 on fedora14
Steps to Reproduce:
1. install machine, have a fixed hostname up to mac address
1.1.1.1 = machine.something.com
2. wait a week or longer when your local dhcp server changes your IP but not
hostname
1.1.1.159 = machine.something.com
[root at machine.something.com ~]# host machine.something.com
machine.something.com has address 1.1.1.159
ifconfig shows the same
3. gethostbyname(gethostname()) shows wrong IP, the original one
Actual results:
[root at machine.something.com ~]# python
Python 2.4.3 (#1, Jun 11 2009, 14:09:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from socket import gethostname
>>> from socket import gethostbyname
>>> gethostname()
'machine.something.com'
>>> gethostbyname(gethostname())
'1.1.1.1'
>>>
Expected results:
gethostbyname(gethostname()) will return your actual IP, 1.1.1.159
Other:
1.1.1.1 = machine.something.com is added in /etc/hosts in the time of OS installation , then its not changed
----------
components: IO
messages: 125298
nosy: psklenar
priority: normal
severity: normal
status: open
title: gethostbyname(gethostname()) is wrong when IP is changed
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10821>
_______________________________________
More information about the Python-bugs-list
mailing list