Python Forum
Python built on a RHEL, Fedora, or CentOS system gives bad getfqdn() Result
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python built on a RHEL, Fedora, or CentOS system gives bad getfqdn() Result
#1
I've run into a situation on any Red Hat-based Linux system where the socket class' getfqdn() function is returning a result related to the DNS thieves "barefruit.co.uk" if the system is connected to the network:
$ ./python 
Python 2.3 (#1, Apr 28 2018, 17:28:50) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.getfqdn()
'unallocated.barefruit.co.uk'
>>> 
That is from a 2.3 build, but I receive the same result with 2.7 and 3.4 - both with the Python supplied with the OS or with a version that I build myself (such as 2.3).

If I disconnect the system from the net, i get the proper result of - for example - "centos764.build.tolisgroup.com".

Using "hostname --fqdn" provides the proper result in both scenarios.

I have validated my /etc/hosts and /etc/resolv.conf files and they are correct.

Any other non-Red Hat Linux does not exhibit this curiosity (Mint, Ubuntu, Debian, Slack, Arch, OpenSuSE all tested).

Has anyone else run into this or have an idea of the cause and a potential fix?

Tim
Reply
#2
I am running Arch and two Ubuntu-based distros and I have no this issue. I didn't know this method but the repl tels me that without an argument it should return the localhost? Arch now.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
I received an answer from another user off-forum. He received from Cox the following when he reported this:
Quote:"This is expected bahavior[sic]. The Cox Business Online DNS resolvers have NXDOMAIN redirection services that redirect any unknown host to a sponsored search page. You can opt out of this by changing your resolver from .11/.12 to .14."
I did just that, changing my resolv.conf to call .14 for the three servers and the issue is resolved.

Digging into this further, it seems that all of my non-RH systems set the nameserver to 127.0.0.1 and search to build.tolisgroup.com. This results in the proper result in all cases.

This still does not answer the oddity that the RH systems' "hostname --fqdn" and the Python "socket.getfqdn()" return different results.
Reply
#4
hostname --fqdn will look at /etc/hosts.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to open port 8080 in CentOS 7 nikos 0 4,247 Mar-02-2019, 03:02 PM
Last Post: nikos

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020