Can mDNS be used to resolve to a link-local address?avoid IPv6 link local address on interfaceHow to delete...

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

Is this light switch installation safe and legal?

Why to use water tanks from Space shuttle in museum?

What does "Marchentalender" on the front of a postcard mean?

How to properly maintain eye contact with people that have distinctive facial features?

Is it possible to change original filename of an exe?

Thousands and thousands of words

What are the benefits of cryosleep?

Is having a hidden directory under /etc safe?

Where can I find the list of all tendons in the human body?

Why would Lupin kill Pettigrew?

Could IPv6 make NAT / port numbers redundant?

What's the most polite way to tell a manager "shut up and let me work"?

If a massive object like Jupiter flew past the Earth how close would it need to come to pull people off of the surface?

Modern approach to radio buttons

My player wants to cast multiple charges of magic missile from a wand

Looking after a wayward brother in mother's will

What is the indigenous Russian word for a wild boar?

find the Integer value after a string from a file

Why is there a need to modify system call tables in linux?

Are there regional foods in Westeros?

Uncommanded roll at high speed

How to capture more stars?

Different PCB color ( is it different material? )



Can mDNS be used to resolve to a link-local address?


avoid IPv6 link local address on interfaceHow to delete inet6 Link address automatically?Convert MAC address to Link-local address with bashLink Local IPv6 address keeps being automatically assignedAssigning link, site and global IPv6 addressTo stop auto generated IPv6 link local addressReading MLDv2 queries using an IPv6 socketUbuntu pinging from link-local address instead of globalIPv6 link-local address in /etc/hostsUbuntu 14.04.5 LTS sends an IPv6 NS message for link-local address for no obvious reason






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















In an earlier discussion on the topic of IPv6 Link-local addresses I saw a comment which stated:




Some would argue that using addresses instead of host names should be discouraged, for any type of addresses. Using mDNS to map to link-local addresses works fine.




The context of the discussion was that you need to specify an interface when using a link-local address.



I found the above comment surprising because I didn't expect mDNS to supply link information, thus I didn't expect it to "work fine". I constructed a simple test (below) to see if the information supplied by getaddrinfo included a link and I found the following:




  • Passing an address and link (eg: fe80::a:a:a:a%wlp3s0) to getaddrinfo resulted in a sockaddr_in6 with sin6_scope_id set to 3 (the index of my wlan card).


  • Passing a hostname only resolvable by mDNS (which resolves to the same link-local address) resulted in a sockaddr_in6 with sin6_scope_id set to 0, ie no link specified


  • Further I've confirmed that programs including SSH which rely on getaddrinfo to specify a link will fail when mDNS resolves a link-local address. But they will succeed if the IP address and link are specified explicitly.





Was the above comment wrong, or have I made a mistake in the way I test this? Can mDNS resolve to link-local address and specify the link?



For reference I'm testing on Debian Buster Linux version 4.19.0-5-amd647



My nsswitch.conf contains



hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname




Testcode.c



#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>


int main(int arg_count, char ** args)
{
struct addrinfo hints, *servinfo, *p;

for (int i=1; i<arg_count; i++)
{
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET6; // to force IPv6
hints.ai_socktype = SOCK_STREAM;
printf("Checking %sn", args[i]);
if (getaddrinfo(args[i], "https", &hints, &servinfo)) {
perror("getaddrinfo");
continue;
}

for(p = servinfo; p != NULL; p = p->ai_next) {
struct sockaddr_in6 * address = ((struct sockaddr_in6 *)p->ai_addr);
printf("family %d scope %dn", address->sin6_family, address->sin6_scope_id);
}
freeaddrinfo(servinfo);
}

return 0;
}









share|improve this question































    0















    In an earlier discussion on the topic of IPv6 Link-local addresses I saw a comment which stated:




    Some would argue that using addresses instead of host names should be discouraged, for any type of addresses. Using mDNS to map to link-local addresses works fine.




    The context of the discussion was that you need to specify an interface when using a link-local address.



    I found the above comment surprising because I didn't expect mDNS to supply link information, thus I didn't expect it to "work fine". I constructed a simple test (below) to see if the information supplied by getaddrinfo included a link and I found the following:




    • Passing an address and link (eg: fe80::a:a:a:a%wlp3s0) to getaddrinfo resulted in a sockaddr_in6 with sin6_scope_id set to 3 (the index of my wlan card).


    • Passing a hostname only resolvable by mDNS (which resolves to the same link-local address) resulted in a sockaddr_in6 with sin6_scope_id set to 0, ie no link specified


    • Further I've confirmed that programs including SSH which rely on getaddrinfo to specify a link will fail when mDNS resolves a link-local address. But they will succeed if the IP address and link are specified explicitly.





    Was the above comment wrong, or have I made a mistake in the way I test this? Can mDNS resolve to link-local address and specify the link?



    For reference I'm testing on Debian Buster Linux version 4.19.0-5-amd647



    My nsswitch.conf contains



    hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname




    Testcode.c



    #include <stdio.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <arpa/inet.h>
    #include <errno.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <netdb.h>


    int main(int arg_count, char ** args)
    {
    struct addrinfo hints, *servinfo, *p;

    for (int i=1; i<arg_count; i++)
    {
    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_INET6; // to force IPv6
    hints.ai_socktype = SOCK_STREAM;
    printf("Checking %sn", args[i]);
    if (getaddrinfo(args[i], "https", &hints, &servinfo)) {
    perror("getaddrinfo");
    continue;
    }

    for(p = servinfo; p != NULL; p = p->ai_next) {
    struct sockaddr_in6 * address = ((struct sockaddr_in6 *)p->ai_addr);
    printf("family %d scope %dn", address->sin6_family, address->sin6_scope_id);
    }
    freeaddrinfo(servinfo);
    }

    return 0;
    }









    share|improve this question



























      0












      0








      0








      In an earlier discussion on the topic of IPv6 Link-local addresses I saw a comment which stated:




      Some would argue that using addresses instead of host names should be discouraged, for any type of addresses. Using mDNS to map to link-local addresses works fine.




      The context of the discussion was that you need to specify an interface when using a link-local address.



      I found the above comment surprising because I didn't expect mDNS to supply link information, thus I didn't expect it to "work fine". I constructed a simple test (below) to see if the information supplied by getaddrinfo included a link and I found the following:




      • Passing an address and link (eg: fe80::a:a:a:a%wlp3s0) to getaddrinfo resulted in a sockaddr_in6 with sin6_scope_id set to 3 (the index of my wlan card).


      • Passing a hostname only resolvable by mDNS (which resolves to the same link-local address) resulted in a sockaddr_in6 with sin6_scope_id set to 0, ie no link specified


      • Further I've confirmed that programs including SSH which rely on getaddrinfo to specify a link will fail when mDNS resolves a link-local address. But they will succeed if the IP address and link are specified explicitly.





      Was the above comment wrong, or have I made a mistake in the way I test this? Can mDNS resolve to link-local address and specify the link?



      For reference I'm testing on Debian Buster Linux version 4.19.0-5-amd647



      My nsswitch.conf contains



      hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname




      Testcode.c



      #include <stdio.h>
      #include <string.h>
      #include <sys/types.h>
      #include <sys/socket.h>
      #include <arpa/inet.h>
      #include <errno.h>
      #include <stdlib.h>
      #include <unistd.h>
      #include <netdb.h>


      int main(int arg_count, char ** args)
      {
      struct addrinfo hints, *servinfo, *p;

      for (int i=1; i<arg_count; i++)
      {
      memset(&hints, 0, sizeof hints);
      hints.ai_family = AF_INET6; // to force IPv6
      hints.ai_socktype = SOCK_STREAM;
      printf("Checking %sn", args[i]);
      if (getaddrinfo(args[i], "https", &hints, &servinfo)) {
      perror("getaddrinfo");
      continue;
      }

      for(p = servinfo; p != NULL; p = p->ai_next) {
      struct sockaddr_in6 * address = ((struct sockaddr_in6 *)p->ai_addr);
      printf("family %d scope %dn", address->sin6_family, address->sin6_scope_id);
      }
      freeaddrinfo(servinfo);
      }

      return 0;
      }









      share|improve this question
















      In an earlier discussion on the topic of IPv6 Link-local addresses I saw a comment which stated:




      Some would argue that using addresses instead of host names should be discouraged, for any type of addresses. Using mDNS to map to link-local addresses works fine.




      The context of the discussion was that you need to specify an interface when using a link-local address.



      I found the above comment surprising because I didn't expect mDNS to supply link information, thus I didn't expect it to "work fine". I constructed a simple test (below) to see if the information supplied by getaddrinfo included a link and I found the following:




      • Passing an address and link (eg: fe80::a:a:a:a%wlp3s0) to getaddrinfo resulted in a sockaddr_in6 with sin6_scope_id set to 3 (the index of my wlan card).


      • Passing a hostname only resolvable by mDNS (which resolves to the same link-local address) resulted in a sockaddr_in6 with sin6_scope_id set to 0, ie no link specified


      • Further I've confirmed that programs including SSH which rely on getaddrinfo to specify a link will fail when mDNS resolves a link-local address. But they will succeed if the IP address and link are specified explicitly.





      Was the above comment wrong, or have I made a mistake in the way I test this? Can mDNS resolve to link-local address and specify the link?



      For reference I'm testing on Debian Buster Linux version 4.19.0-5-amd647



      My nsswitch.conf contains



      hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname




      Testcode.c



      #include <stdio.h>
      #include <string.h>
      #include <sys/types.h>
      #include <sys/socket.h>
      #include <arpa/inet.h>
      #include <errno.h>
      #include <stdlib.h>
      #include <unistd.h>
      #include <netdb.h>


      int main(int arg_count, char ** args)
      {
      struct addrinfo hints, *servinfo, *p;

      for (int i=1; i<arg_count; i++)
      {
      memset(&hints, 0, sizeof hints);
      hints.ai_family = AF_INET6; // to force IPv6
      hints.ai_socktype = SOCK_STREAM;
      printf("Checking %sn", args[i]);
      if (getaddrinfo(args[i], "https", &hints, &servinfo)) {
      perror("getaddrinfo");
      continue;
      }

      for(p = servinfo; p != NULL; p = p->ai_next) {
      struct sockaddr_in6 * address = ((struct sockaddr_in6 *)p->ai_addr);
      printf("family %d scope %dn", address->sin6_family, address->sin6_scope_id);
      }
      freeaddrinfo(servinfo);
      }

      return 0;
      }






      c ipv6






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 54 mins ago









      JL2210

      1637




      1637










      asked 2 hours ago









      Philip CoulingPhilip Couling

      3,61011427




      3,61011427






















          0






          active

          oldest

          votes












          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',
          autoActivateHeartbeat: false,
          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%2f521629%2fcan-mdns-be-used-to-resolve-to-a-link-local-address%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f521629%2fcan-mdns-be-used-to-resolve-to-a-link-local-address%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

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m