LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2019, 06:54 AM   #1
Prze-moC
LQ Newbie
 
Registered: Jul 2019
Posts: 11

Rep: Reputation: 2
Where "hostname -A" get the domain name from?


Hello,
I had recently migrated my servers between two domains: biz-old.com -> biz-new.net
/etc/hostname contains pute host name, i.e. "my-host" without the domain.
I checked {yp,nis,}domainname and none is set, but "hostname -A" still shows the biz-old.com domain.

What do I need to do, so "hostname -A" shows "my-host.biz-new.net" instead of "my-host.biz-old.com ?

Forgot the distribution name:
Code:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)

Last edited by Prze-moC; 09-25-2019 at 11:53 AM.
 
Old 09-25-2019, 07:34 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by Prze-moC View Post
What do I need to do, so "hostname -A" shows "my-host.biz-new.net" instead of "my-host.biz-old.com ?
Code:
man hostname
and read about what -A actually does and read the section on THE FQDN You may have to change a number of things in a number of places to achieve your result.
 
1 members found this post helpful.
Old 09-25-2019, 10:59 AM   #3
Prze-moC
LQ Newbie
 
Registered: Jul 2019
Posts: 11

Original Poster
Rep: Reputation: 2
Thumbs down

Code:
man hostname
mentions something about "the resolver", "getaddrinfo" and "gethostname" which are neither any commands or have manual entres.
It also mentions to add the domain into /etc/hostname. Well, tried that and
Code:
hostname -A
ignores that file showing the old domain.
I guess the key is to translate a sentence: "enumerates all configured network addresses on all configured network interfaces, and translates them to DNS domain names" into an actionable set of commands.

Can anyone of you, black-screen gurus, help me with that?

Last edited by Prze-moC; 09-25-2019 at 11:15 AM.
 
Old 09-25-2019, 11:27 AM   #4
urbanwks
Member
 
Registered: Sep 2003
Distribution: Slackware64-Current, FreeBSD 12.1, Alpine 5.4, Manjaro 19, Alpine on WSL [Win10]
Posts: 194

Rep: Reputation: 213Reputation: 213Reputation: 213
Did you update /etc/hostname, or /etc/HOSTNAME?

You don't mention what distro you're using, but on mine it's the latter. Remember case counts in Linux. That's just my initial thought.
 
Old 09-25-2019, 12:03 PM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by Prze-moC View Post
Code:
man hostname
mentions something about "the resolver", "getaddrinfo" and "gethostname" which are neither any commands or have manual entres.
It also mentions to add the domain into /etc/hostname. Well, tried that and
Code:
hostname -A
ignores that file showing the old domain.
I guess the key is to translate a sentence: "enumerates all configured network addresses on all configured network interfaces, and translates them to DNS domain names" into an actionable set of commands.

Can anyone of you, black-screen gurus, help me with that?
From man hostname:
Quote:
-A, --all-fqdns
Displays all FQDNs of the machine. This option enumerates all configured network addresses on all configured network interfaces, and translates them to DNS domain names. Addresses that cannot be translated (i.e.
because they do not have an appropriate reverse DNS entry) are skipped
. Note that different addresses may resolve to the same name, therefore the output may contain duplicate entries. Do not make any assumptions about
the order of the output.
On my server, there are around 300 FQDNs - only one show up using hostname -A, because there's only one rDNS set up.

What is the rDNS setting for your server?
 
Old 09-25-2019, 01:37 PM   #6
Prze-moC
LQ Newbie
 
Registered: Jul 2019
Posts: 11

Original Poster
Rep: Reputation: 2
Indeed a network must be involved in my situation as I cannot find anything locally that would mention the old domain.
Unfortunately, I don't really know what are you talking about (I need actionable set of commands), but when I try DNS then I get the new domain (i.e. output of "host -v my-host").
If DNS gives me the new domain then, where does "hostname -A" take the old domain from?
 
Old 09-25-2019, 01:50 PM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by Prze-moC View Post
Indeed a network must be involved in my situation as I cannot find anything locally that would mention the old domain.
Unfortunately, I don't really know what are you talking about (I need actionable set of commands), but when I try DNS then I get the new domain (i.e. output of "host -v my-host").
If DNS gives me the new domain then, where does "hostname -A" take the old domain from?
See #5:
Quote:
This option enumerates all configured network addresses on all configured network interfaces, and translates them to DNS domain names
so the A option takes the IP addresses, looks up the rDNS for each and reports the host name, if it finds an rDNS (reverse DNS).
What does
Code:
dig -x <your IP address>
return? Should be the old host name.
 
Old 09-25-2019, 02:11 PM   #8
Prze-moC
LQ Newbie
 
Registered: Jul 2019
Posts: 11

Original Poster
Rep: Reputation: 2
# dig -x ###.###.###.###
;; Got bad packet: bad label type
128 bytes
1c e7 85 83 00 01 00 00 00 01 00 01 02 32 34 02 .............24.
...
00 78 57 fe e0 00 00 2a 30 00 00 0e 10 00 09 3a .xW....*0......:
80 00 00 02 58 00 00 29 10 00 00 00 00 00 00 00 ....X..)........

Last edited by Prze-moC; 09-26-2019 at 05:27 AM. Reason: masking real IP and name
 
Old 09-25-2019, 03:50 PM   #9
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Strange output.
Did you munge the IP address? That return is giving a sub-domain of ###.com, formerly known as CSC.
That IP gives me a sub-domain of ###.com, also associated with DXC
(HP consulting merged with CSC. DXC is the resulting company)

Is grens0.### or plsekatlastst01.### the "old" hostname?

Do you work for DXC? If so, I'd recommend you talk to your IT department. What you're doing could be career-limiting. (This from a retired CSC techie)

Last edited by scasey; 09-26-2019 at 11:41 AM.
 
Old 09-26-2019, 05:26 AM   #10
Prze-moC
LQ Newbie
 
Registered: Jul 2019
Posts: 11

Original Poster
Rep: Reputation: 2
Career-limiting might be that I posted real IP and names. It is worrying that you could get the server name from it while it is supposed to be internal and the IP NATted.
I'll wipe out my previous post... Can you also edit yours, please?

Yes, plsek.... is the old hostname and old domain names. I can only guess, that as the DNS contains two entries for the old and new domains then "hostname -A" just picks the first DNS entry which by coincidence is the old domain.
 
Old 09-26-2019, 11:37 AM   #11
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by Prze-moC View Post
Career-limiting might be that I posted real IP and names. It is worrying that you could get the server name from it while it is supposed to be internal and the IP NATted.
I'll wipe out my previous post... Can you also edit yours, please?

Yes, plsek.... is the old hostname and old domain names. I can only guess, that as the DNS contains two entries for the old and new domains then "hostname -A" just picks the first DNS entry which by coincidence is the old domain.
Edit done.

The man page notes that if there are multiple domain names for an IP address, hostname -A should report all of them.

That the IP resolves publicly simply means that it's defined in a public name server, not necessarily that it is accessible by the public...but yes, you should probably escalate the problem.
 
Old 09-28-2019, 05:21 PM   #12
Prze-moC
LQ Newbie
 
Registered: Jul 2019
Posts: 11

Original Poster
Rep: Reputation: 2
I presume the domain name is taken from the public DNS.
When on my home network (= using my ISP dns servers) then my server's IP resolves to the old domain name (as found by @scasey).
When on the corporate network then "nslookup" or "dig -x" returns the error ("Got bad packet: bad label type" mentioned above). Surprisingly (at least to me), the corporate DNS works OK with old and new domains resolving to the proper IP when pinging or telneting.

Maybe because of the error in the internal DNS a public DNS is queried?
 
  


Reply

Tags
hostname change



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HOSTNAME = hostname -> HOSTNAME: command not found ? thomas2004ch Linux - Software 2 08-26-2013 08:25 PM
"domain-name" and "host-name" options in dhcpd.conf m4rtin Linux - Server 3 09-20-2012 08:21 AM
Sendmail doubling sender domain- ex. hostname.domain.net.domain.net halborr Slackware 7 08-23-2010 08:37 AM
Set up .name.domain, but how do I set .domain/name Karas Linux - Newbie 1 12-03-2009 09:31 AM
what would make ever virtual domain name resolve to one domain name on my system kuplo Linux - Newbie 1 11-14-2005 06:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration