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










share|improve this question




























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










    share|improve this question


























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










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 13 '17 at 12:36









      Community

      1




      1










      asked Jun 19 '14 at 23:37









      Naftuli Kay

      12k55156250




      12k55156250






















          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:




          1. hostname -f

          2. dnsdomainname

          3. parsing resolv.conf for a "domain" or "search" entry






          share|improve this answer























          • Ah heck! that link to the Facter source code is no long valid.
            – Red Cricket
            Sep 6 '17 at 6:34


















          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.






          share|improve this answer





















          • 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










          • @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











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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

























          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:




          1. hostname -f

          2. dnsdomainname

          3. parsing resolv.conf for a "domain" or "search" entry






          share|improve this answer























          • Ah heck! that link to the Facter source code is no long valid.
            – Red Cricket
            Sep 6 '17 at 6:34















          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:




          1. hostname -f

          2. dnsdomainname

          3. parsing resolv.conf for a "domain" or "search" entry






          share|improve this answer























          • Ah heck! that link to the Facter source code is no long valid.
            – Red Cricket
            Sep 6 '17 at 6:34













          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:




          1. hostname -f

          2. dnsdomainname

          3. parsing resolv.conf for a "domain" or "search" entry






          share|improve this answer














          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:




          1. hostname -f

          2. dnsdomainname

          3. parsing resolv.conf for a "domain" or "search" entry







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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


















          • 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












          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.






          share|improve this answer





















          • 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










          • @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















          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.






          share|improve this answer





















          • 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










          • @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













          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










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










          • 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


















          • 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










          • @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
















          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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Morgemoulin

          Scott Moir

          Souastre