Bug 634147 - gethostbyname(gethostname()) is wrong when IP is changed
Summary: gethostbyname(gethostname()) is wrong when IP is changed
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: python
Version: 5.5
Hardware: All
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Dave Malcolm
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-09-15 10:56 UTC by Petr Sklenar
Modified: 2011-01-03 18:45 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-01-03 18:45:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Petr Sklenar 2010-09-15 10:56:42 UTC
Description of problem:
gethostbyname(gethostname()) is wrong when IP is changed

Version-Release number of selected component (if applicable):
libxml2-python-2.6.26-2.1.2.8
libselinux-python-1.33.4-5.5.el5
audit-libs-python-1.7.17-3.el5
python-iniparse-0.2.3-4.el5
python-urlgrabber-3.1.0-5.el5
notify-python-0.1.0-3.fc6
gnome-python2-bonobo-2.16.0-1.fc6
MySQL-python-1.2.1-1
python-dmidecode-3.10.8-4.el5
python-sqlite-1.1.7-1.2.1
gamin-python-0.1.7-8.el5
python-numeric-23.7-2.2.2
python-elementtree-1.2.6-5
gnome-python2-canvas-2.16.0-1.fc6
gnome-python2-gconf-2.16.0-1.fc6
python-2.4.3-27.el5
dbus-python-0.70-9.el5_4
rpm-python-4.4.2.3-18.el5
gnome-python2-2.16.0-1.fc6
gnome-python2-gnomevfs-2.16.0-1.fc6
rhts-devel-python-3.3-54.el5

How reproducible:


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.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.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

Additional info:

Comment 1 Miroslav Suchý 2010-09-15 11:29:07 UTC
This is IMHO not python bug, but probably initscripts component.
gethostbyname() just utilize /etc/hosts and this file will have
1.1.1.159  machine.something.com
There is nothing else python can do.
The problem is that network script do not change /etc/hosts.

Comment 3 RHEL Program Management 2010-12-07 10:30:01 UTC
This request was evaluated by Red Hat Product Management for inclusion in Red Hat Enterprise Linux 5.6 and Red Hat does not plan to fix this issue the currently developed update.

Contact your manager or support representative in case you need to escalate this bug.

Comment 5 RHEL Program Management 2011-01-03 18:45:06 UTC
Development Management has reviewed and declined this request.  You may appeal
this decision by reopening this request.


Note You need to log in before you can comment on or make changes to this bug.