Determine FQDN when hostname doesn't give it?
up vote
7
down vote
favorite
In another question, I found that Puppet was generating certificates for my machine's FQDN but not the simple host name. In that example, kungfumaster
was the hostname and was the value retrieved by running hostname
. Puppet was generating certificates which specified the FQDN kungfumaster.domain.com
.
How did Puppet determine that this was my FQDN? I have tried all of the following and not seen anything matching *.domain.com
:
$ hostname -a && hostname -d && hostname --domain && hostname -f &&
hostname --fqdn && hostname -A && hostname --long
kungfumaster
kungfumaster
kungfumaster
kungfumaster
How can I get kungfumaster.domain.com
from Bash? I've noticed that domain.com
does in fact exist in /etc/resolv.conf
, but I haven't been able to find it anywhere else.
I basically want to get the FQDN of the current machine as a string. The other solutions here on unix.se haven't worked for me. (ie: dnsdomainname
, domainname
, etc.)
hostname puppet
add a comment |
up vote
7
down vote
favorite
In another question, I found that Puppet was generating certificates for my machine's FQDN but not the simple host name. In that example, kungfumaster
was the hostname and was the value retrieved by running hostname
. Puppet was generating certificates which specified the FQDN kungfumaster.domain.com
.
How did Puppet determine that this was my FQDN? I have tried all of the following and not seen anything matching *.domain.com
:
$ hostname -a && hostname -d && hostname --domain && hostname -f &&
hostname --fqdn && hostname -A && hostname --long
kungfumaster
kungfumaster
kungfumaster
kungfumaster
How can I get kungfumaster.domain.com
from Bash? I've noticed that domain.com
does in fact exist in /etc/resolv.conf
, but I haven't been able to find it anywhere else.
I basically want to get the FQDN of the current machine as a string. The other solutions here on unix.se haven't worked for me. (ie: dnsdomainname
, domainname
, etc.)
hostname puppet
add a comment |
up vote
7
down vote
favorite
up vote
7
down vote
favorite
In another question, I found that Puppet was generating certificates for my machine's FQDN but not the simple host name. In that example, kungfumaster
was the hostname and was the value retrieved by running hostname
. Puppet was generating certificates which specified the FQDN kungfumaster.domain.com
.
How did Puppet determine that this was my FQDN? I have tried all of the following and not seen anything matching *.domain.com
:
$ hostname -a && hostname -d && hostname --domain && hostname -f &&
hostname --fqdn && hostname -A && hostname --long
kungfumaster
kungfumaster
kungfumaster
kungfumaster
How can I get kungfumaster.domain.com
from Bash? I've noticed that domain.com
does in fact exist in /etc/resolv.conf
, but I haven't been able to find it anywhere else.
I basically want to get the FQDN of the current machine as a string. The other solutions here on unix.se haven't worked for me. (ie: dnsdomainname
, domainname
, etc.)
hostname puppet
In another question, I found that Puppet was generating certificates for my machine's FQDN but not the simple host name. In that example, kungfumaster
was the hostname and was the value retrieved by running hostname
. Puppet was generating certificates which specified the FQDN kungfumaster.domain.com
.
How did Puppet determine that this was my FQDN? I have tried all of the following and not seen anything matching *.domain.com
:
$ hostname -a && hostname -d && hostname --domain && hostname -f &&
hostname --fqdn && hostname -A && hostname --long
kungfumaster
kungfumaster
kungfumaster
kungfumaster
How can I get kungfumaster.domain.com
from Bash? I've noticed that domain.com
does in fact exist in /etc/resolv.conf
, but I haven't been able to find it anywhere else.
I basically want to get the FQDN of the current machine as a string. The other solutions here on unix.se haven't worked for me. (ie: dnsdomainname
, domainname
, etc.)
hostname puppet
hostname puppet
edited Apr 13 '17 at 12:36
Community♦
1
1
asked Jun 19 '14 at 23:37
Naftuli Kay
12k55156250
12k55156250
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
7
down vote
accepted
It appears that under-the-hood, Puppet uses Facter to evaluate the domain names:
$ facter domain
domain.com
$ facter hostname
kungfumaster
$ facter fqdn
kungfumaster.domain.com
The answer is in the relevant Facter source code.
It does the following in order and uses the first one that appears to contain a domain name:
- hostname -f
- dnsdomainname
- parsing resolv.conf for a "domain" or "search" entry
Ah heck! that link to the Facter source code is no long valid.
– Red Cricket
Sep 6 '17 at 6:34
add a comment |
up vote
2
down vote
Probably because your system is part of a domain network that assigns a domain name. For example in my case, my router resolves all hostnames in the form of host.lan
, "lan" being my domain, and "host" the name of my system.
The FQDN most likely comes from your router DNS, just run whatever you like of these commands:
nslookup your-ip-here
dig -x your-ip-here
host your-ip-here
An example using dig
:
dig @10.0.0.1 -x 10.0.0.1
; <<>> DiG 9.9.5-4-Debian <<>> @10.0.0.1 -x 10.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11384
;; flags: qr aa rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1.0.0.10.in-addr.arpa. IN PTR
;; ADDITIONAL SECTION:
1.0.0.10.in-addr.arpa. 86400 IN PTR dsldevice.lan.
;; Query time: 2181 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Thu Jun 19 20:01:32 AST 2014
;; MSG SIZE rcvd: 77
Since I use my own DNS and not the router's I have to set the domain to query in the @
part. I'm querying the routers' own domain name.
You will find that it will return the domain name as your DNS/router sees you. There are various ways to disable this in the router, but I've found that the most easier way is just using other DNS.
It actually doesn't do a DNS lookup at all, so this answer is wrong. See Naftuli Tzvi Kay's answer with my edit.
– jordanm
Jun 20 '14 at 0:31
Actually, it looks likednsdomainname
can do a lookup if your own host is not in/etc/hosts
.
– jordanm
Jun 20 '14 at 0:33
@jordanm so, it's not wrong?
– Braiam
Jun 20 '14 at 0:37
Well, in OP's particular context it is, but it could be correct for some users. The OP saiddnsdomainname
did not return the domain name which is the only link in the chain that could do the dns lookup.
– jordanm
Jun 20 '14 at 0:38
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
It appears that under-the-hood, Puppet uses Facter to evaluate the domain names:
$ facter domain
domain.com
$ facter hostname
kungfumaster
$ facter fqdn
kungfumaster.domain.com
The answer is in the relevant Facter source code.
It does the following in order and uses the first one that appears to contain a domain name:
- hostname -f
- dnsdomainname
- parsing resolv.conf for a "domain" or "search" entry
Ah heck! that link to the Facter source code is no long valid.
– Red Cricket
Sep 6 '17 at 6:34
add a comment |
up vote
7
down vote
accepted
It appears that under-the-hood, Puppet uses Facter to evaluate the domain names:
$ facter domain
domain.com
$ facter hostname
kungfumaster
$ facter fqdn
kungfumaster.domain.com
The answer is in the relevant Facter source code.
It does the following in order and uses the first one that appears to contain a domain name:
- hostname -f
- dnsdomainname
- parsing resolv.conf for a "domain" or "search" entry
Ah heck! that link to the Facter source code is no long valid.
– Red Cricket
Sep 6 '17 at 6:34
add a comment |
up vote
7
down vote
accepted
up vote
7
down vote
accepted
It appears that under-the-hood, Puppet uses Facter to evaluate the domain names:
$ facter domain
domain.com
$ facter hostname
kungfumaster
$ facter fqdn
kungfumaster.domain.com
The answer is in the relevant Facter source code.
It does the following in order and uses the first one that appears to contain a domain name:
- hostname -f
- dnsdomainname
- parsing resolv.conf for a "domain" or "search" entry
It appears that under-the-hood, Puppet uses Facter to evaluate the domain names:
$ facter domain
domain.com
$ facter hostname
kungfumaster
$ facter fqdn
kungfumaster.domain.com
The answer is in the relevant Facter source code.
It does the following in order and uses the first one that appears to contain a domain name:
- hostname -f
- dnsdomainname
- parsing resolv.conf for a "domain" or "search" entry
edited Nov 23 at 6:29
TerrenceSun
237
237
answered Jun 20 '14 at 0:08
Naftuli Kay
12k55156250
12k55156250
Ah heck! that link to the Facter source code is no long valid.
– Red Cricket
Sep 6 '17 at 6:34
add a comment |
Ah heck! that link to the Facter source code is no long valid.
– Red Cricket
Sep 6 '17 at 6:34
Ah heck! that link to the Facter source code is no long valid.
– Red Cricket
Sep 6 '17 at 6:34
Ah heck! that link to the Facter source code is no long valid.
– Red Cricket
Sep 6 '17 at 6:34
add a comment |
up vote
2
down vote
Probably because your system is part of a domain network that assigns a domain name. For example in my case, my router resolves all hostnames in the form of host.lan
, "lan" being my domain, and "host" the name of my system.
The FQDN most likely comes from your router DNS, just run whatever you like of these commands:
nslookup your-ip-here
dig -x your-ip-here
host your-ip-here
An example using dig
:
dig @10.0.0.1 -x 10.0.0.1
; <<>> DiG 9.9.5-4-Debian <<>> @10.0.0.1 -x 10.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11384
;; flags: qr aa rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1.0.0.10.in-addr.arpa. IN PTR
;; ADDITIONAL SECTION:
1.0.0.10.in-addr.arpa. 86400 IN PTR dsldevice.lan.
;; Query time: 2181 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Thu Jun 19 20:01:32 AST 2014
;; MSG SIZE rcvd: 77
Since I use my own DNS and not the router's I have to set the domain to query in the @
part. I'm querying the routers' own domain name.
You will find that it will return the domain name as your DNS/router sees you. There are various ways to disable this in the router, but I've found that the most easier way is just using other DNS.
It actually doesn't do a DNS lookup at all, so this answer is wrong. See Naftuli Tzvi Kay's answer with my edit.
– jordanm
Jun 20 '14 at 0:31
Actually, it looks likednsdomainname
can do a lookup if your own host is not in/etc/hosts
.
– jordanm
Jun 20 '14 at 0:33
@jordanm so, it's not wrong?
– Braiam
Jun 20 '14 at 0:37
Well, in OP's particular context it is, but it could be correct for some users. The OP saiddnsdomainname
did not return the domain name which is the only link in the chain that could do the dns lookup.
– jordanm
Jun 20 '14 at 0:38
add a comment |
up vote
2
down vote
Probably because your system is part of a domain network that assigns a domain name. For example in my case, my router resolves all hostnames in the form of host.lan
, "lan" being my domain, and "host" the name of my system.
The FQDN most likely comes from your router DNS, just run whatever you like of these commands:
nslookup your-ip-here
dig -x your-ip-here
host your-ip-here
An example using dig
:
dig @10.0.0.1 -x 10.0.0.1
; <<>> DiG 9.9.5-4-Debian <<>> @10.0.0.1 -x 10.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11384
;; flags: qr aa rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1.0.0.10.in-addr.arpa. IN PTR
;; ADDITIONAL SECTION:
1.0.0.10.in-addr.arpa. 86400 IN PTR dsldevice.lan.
;; Query time: 2181 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Thu Jun 19 20:01:32 AST 2014
;; MSG SIZE rcvd: 77
Since I use my own DNS and not the router's I have to set the domain to query in the @
part. I'm querying the routers' own domain name.
You will find that it will return the domain name as your DNS/router sees you. There are various ways to disable this in the router, but I've found that the most easier way is just using other DNS.
It actually doesn't do a DNS lookup at all, so this answer is wrong. See Naftuli Tzvi Kay's answer with my edit.
– jordanm
Jun 20 '14 at 0:31
Actually, it looks likednsdomainname
can do a lookup if your own host is not in/etc/hosts
.
– jordanm
Jun 20 '14 at 0:33
@jordanm so, it's not wrong?
– Braiam
Jun 20 '14 at 0:37
Well, in OP's particular context it is, but it could be correct for some users. The OP saiddnsdomainname
did not return the domain name which is the only link in the chain that could do the dns lookup.
– jordanm
Jun 20 '14 at 0:38
add a comment |
up vote
2
down vote
up vote
2
down vote
Probably because your system is part of a domain network that assigns a domain name. For example in my case, my router resolves all hostnames in the form of host.lan
, "lan" being my domain, and "host" the name of my system.
The FQDN most likely comes from your router DNS, just run whatever you like of these commands:
nslookup your-ip-here
dig -x your-ip-here
host your-ip-here
An example using dig
:
dig @10.0.0.1 -x 10.0.0.1
; <<>> DiG 9.9.5-4-Debian <<>> @10.0.0.1 -x 10.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11384
;; flags: qr aa rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1.0.0.10.in-addr.arpa. IN PTR
;; ADDITIONAL SECTION:
1.0.0.10.in-addr.arpa. 86400 IN PTR dsldevice.lan.
;; Query time: 2181 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Thu Jun 19 20:01:32 AST 2014
;; MSG SIZE rcvd: 77
Since I use my own DNS and not the router's I have to set the domain to query in the @
part. I'm querying the routers' own domain name.
You will find that it will return the domain name as your DNS/router sees you. There are various ways to disable this in the router, but I've found that the most easier way is just using other DNS.
Probably because your system is part of a domain network that assigns a domain name. For example in my case, my router resolves all hostnames in the form of host.lan
, "lan" being my domain, and "host" the name of my system.
The FQDN most likely comes from your router DNS, just run whatever you like of these commands:
nslookup your-ip-here
dig -x your-ip-here
host your-ip-here
An example using dig
:
dig @10.0.0.1 -x 10.0.0.1
; <<>> DiG 9.9.5-4-Debian <<>> @10.0.0.1 -x 10.0.0.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11384
;; flags: qr aa rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1.0.0.10.in-addr.arpa. IN PTR
;; ADDITIONAL SECTION:
1.0.0.10.in-addr.arpa. 86400 IN PTR dsldevice.lan.
;; Query time: 2181 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Thu Jun 19 20:01:32 AST 2014
;; MSG SIZE rcvd: 77
Since I use my own DNS and not the router's I have to set the domain to query in the @
part. I'm querying the routers' own domain name.
You will find that it will return the domain name as your DNS/router sees you. There are various ways to disable this in the router, but I've found that the most easier way is just using other DNS.
answered Jun 20 '14 at 0:03
Braiam
22.9k1974135
22.9k1974135
It actually doesn't do a DNS lookup at all, so this answer is wrong. See Naftuli Tzvi Kay's answer with my edit.
– jordanm
Jun 20 '14 at 0:31
Actually, it looks likednsdomainname
can do a lookup if your own host is not in/etc/hosts
.
– jordanm
Jun 20 '14 at 0:33
@jordanm so, it's not wrong?
– Braiam
Jun 20 '14 at 0:37
Well, in OP's particular context it is, but it could be correct for some users. The OP saiddnsdomainname
did not return the domain name which is the only link in the chain that could do the dns lookup.
– jordanm
Jun 20 '14 at 0:38
add a comment |
It actually doesn't do a DNS lookup at all, so this answer is wrong. See Naftuli Tzvi Kay's answer with my edit.
– jordanm
Jun 20 '14 at 0:31
Actually, it looks likednsdomainname
can do a lookup if your own host is not in/etc/hosts
.
– jordanm
Jun 20 '14 at 0:33
@jordanm so, it's not wrong?
– Braiam
Jun 20 '14 at 0:37
Well, in OP's particular context it is, but it could be correct for some users. The OP saiddnsdomainname
did not return the domain name which is the only link in the chain that could do the dns lookup.
– jordanm
Jun 20 '14 at 0:38
It actually doesn't do a DNS lookup at all, so this answer is wrong. See Naftuli Tzvi Kay's answer with my edit.
– jordanm
Jun 20 '14 at 0:31
It actually doesn't do a DNS lookup at all, so this answer is wrong. See Naftuli Tzvi Kay's answer with my edit.
– jordanm
Jun 20 '14 at 0:31
Actually, it looks like
dnsdomainname
can do a lookup if your own host is not in /etc/hosts
.– jordanm
Jun 20 '14 at 0:33
Actually, it looks like
dnsdomainname
can do a lookup if your own host is not in /etc/hosts
.– jordanm
Jun 20 '14 at 0:33
@jordanm so, it's not wrong?
– Braiam
Jun 20 '14 at 0:37
@jordanm so, it's not wrong?
– Braiam
Jun 20 '14 at 0:37
Well, in OP's particular context it is, but it could be correct for some users. The OP said
dnsdomainname
did not return the domain name which is the only link in the chain that could do the dns lookup.– jordanm
Jun 20 '14 at 0:38
Well, in OP's particular context it is, but it could be correct for some users. The OP said
dnsdomainname
did not return the domain name which is the only link in the chain that could do the dns lookup.– jordanm
Jun 20 '14 at 0:38
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f138165%2fdetermine-fqdn-when-hostname-doesnt-give-it%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown