To overcome differences in format of ifconfig Ubuntu16.04 and Ubuntu17.01

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












Background:



I am checking the list available interfaces on Linux using the ifconfig command.



However there is a difference in the format of the output of ifconfig in ubuntu 16.04 and ubuntu 17.10.



On checking further , the net-tools package has been upgraded (from net-tools 1.60 TO net-tools 2.10-alpha)in the ubuntu17.10 and the latest ifconfig outputs the network interface names with a colon (':').
On older version :




$ ifconfig --version
net-tools 1.60 ifconfig 1.42 (2001-04-13)



$ ifconfig



enp0s3 Link encap:Ethernet




On the newer version




$ ifconfig --version net-tools 2.10-alpha



$ifconfig



ens160: flags=4163 mtu 1500



lo: flags=73 mtu 65536




This can break some tools which does take into account or expect the extra ':' in the output.



Question:



Is there a way to obtain the list of network interface in a reliable way, such that any change in the format of ifconfig output does not affect tools using it ? Is there alternative for ifconfig that can be used in consistent manner?







share|improve this question
























    up vote
    1
    down vote

    favorite












    Background:



    I am checking the list available interfaces on Linux using the ifconfig command.



    However there is a difference in the format of the output of ifconfig in ubuntu 16.04 and ubuntu 17.10.



    On checking further , the net-tools package has been upgraded (from net-tools 1.60 TO net-tools 2.10-alpha)in the ubuntu17.10 and the latest ifconfig outputs the network interface names with a colon (':').
    On older version :




    $ ifconfig --version
    net-tools 1.60 ifconfig 1.42 (2001-04-13)



    $ ifconfig



    enp0s3 Link encap:Ethernet




    On the newer version




    $ ifconfig --version net-tools 2.10-alpha



    $ifconfig



    ens160: flags=4163 mtu 1500



    lo: flags=73 mtu 65536




    This can break some tools which does take into account or expect the extra ':' in the output.



    Question:



    Is there a way to obtain the list of network interface in a reliable way, such that any change in the format of ifconfig output does not affect tools using it ? Is there alternative for ifconfig that can be used in consistent manner?







    share|improve this question






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Background:



      I am checking the list available interfaces on Linux using the ifconfig command.



      However there is a difference in the format of the output of ifconfig in ubuntu 16.04 and ubuntu 17.10.



      On checking further , the net-tools package has been upgraded (from net-tools 1.60 TO net-tools 2.10-alpha)in the ubuntu17.10 and the latest ifconfig outputs the network interface names with a colon (':').
      On older version :




      $ ifconfig --version
      net-tools 1.60 ifconfig 1.42 (2001-04-13)



      $ ifconfig



      enp0s3 Link encap:Ethernet




      On the newer version




      $ ifconfig --version net-tools 2.10-alpha



      $ifconfig



      ens160: flags=4163 mtu 1500



      lo: flags=73 mtu 65536




      This can break some tools which does take into account or expect the extra ':' in the output.



      Question:



      Is there a way to obtain the list of network interface in a reliable way, such that any change in the format of ifconfig output does not affect tools using it ? Is there alternative for ifconfig that can be used in consistent manner?







      share|improve this question












      Background:



      I am checking the list available interfaces on Linux using the ifconfig command.



      However there is a difference in the format of the output of ifconfig in ubuntu 16.04 and ubuntu 17.10.



      On checking further , the net-tools package has been upgraded (from net-tools 1.60 TO net-tools 2.10-alpha)in the ubuntu17.10 and the latest ifconfig outputs the network interface names with a colon (':').
      On older version :




      $ ifconfig --version
      net-tools 1.60 ifconfig 1.42 (2001-04-13)



      $ ifconfig



      enp0s3 Link encap:Ethernet




      On the newer version




      $ ifconfig --version net-tools 2.10-alpha



      $ifconfig



      ens160: flags=4163 mtu 1500



      lo: flags=73 mtu 65536




      This can break some tools which does take into account or expect the extra ':' in the output.



      Question:



      Is there a way to obtain the list of network interface in a reliable way, such that any change in the format of ifconfig output does not affect tools using it ? Is there alternative for ifconfig that can be used in consistent manner?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 29 '17 at 4:01









      Sudarshan Srinivasan

      82




      82




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          The net-tools package was deprecated for some time, being replaced by iproute2 (ip being the primary tool in that package). Many distributions no longer even ship net-tools as part of their base install.



          Development of net-tools has since restarted, but this has resulted in a number of the tools being enhanced in compatibility breaking ways, as you've seen with ifconfig. From NEWS.Debian.gz on a Debian 9.0 system:




          After 15 years without upstream development, net-tools is being worked on again, fixing many long-standing issues.
          The bad news is that the output of many commands has changed, and it is sure to break scripts that relied on parsing it.




          For that reason it may be an idea to adapt your scripts to use the iproute2 tools. For example, ip link should give you similar information to your bare ifconfig above. The one downside to this approach is that it breaks compatibility with non-Linux systems, almost all of which use ifconfig.






          share|improve this answer






















          • Thanks iproute2 looks to be supported on most the distributions and embedded distros (via busybox)
            – Sudarshan Srinivasan
            Feb 17 at 9:38


















          up vote
          1
          down vote













          An alternative way to list all interfaces in Linux from shell is reading /proc/net/dev, which have a more stable format than the output of ifconfig(8) from net-tools.



          For example, to get name of interfaces:



          whr@debianjessie:~$ sed -r -e 1,2d -e 's/^ +//' -e 's/: .+//' /proc/net/dev
          ppp0
          lo
          eth0
          eth1





          share|improve this answer






















            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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f407637%2fto-overcome-differences-in-format-of-ifconfig-ubuntu16-04-and-ubuntu17-01%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote



            accepted










            The net-tools package was deprecated for some time, being replaced by iproute2 (ip being the primary tool in that package). Many distributions no longer even ship net-tools as part of their base install.



            Development of net-tools has since restarted, but this has resulted in a number of the tools being enhanced in compatibility breaking ways, as you've seen with ifconfig. From NEWS.Debian.gz on a Debian 9.0 system:




            After 15 years without upstream development, net-tools is being worked on again, fixing many long-standing issues.
            The bad news is that the output of many commands has changed, and it is sure to break scripts that relied on parsing it.




            For that reason it may be an idea to adapt your scripts to use the iproute2 tools. For example, ip link should give you similar information to your bare ifconfig above. The one downside to this approach is that it breaks compatibility with non-Linux systems, almost all of which use ifconfig.






            share|improve this answer






















            • Thanks iproute2 looks to be supported on most the distributions and embedded distros (via busybox)
              – Sudarshan Srinivasan
              Feb 17 at 9:38















            up vote
            2
            down vote



            accepted










            The net-tools package was deprecated for some time, being replaced by iproute2 (ip being the primary tool in that package). Many distributions no longer even ship net-tools as part of their base install.



            Development of net-tools has since restarted, but this has resulted in a number of the tools being enhanced in compatibility breaking ways, as you've seen with ifconfig. From NEWS.Debian.gz on a Debian 9.0 system:




            After 15 years without upstream development, net-tools is being worked on again, fixing many long-standing issues.
            The bad news is that the output of many commands has changed, and it is sure to break scripts that relied on parsing it.




            For that reason it may be an idea to adapt your scripts to use the iproute2 tools. For example, ip link should give you similar information to your bare ifconfig above. The one downside to this approach is that it breaks compatibility with non-Linux systems, almost all of which use ifconfig.






            share|improve this answer






















            • Thanks iproute2 looks to be supported on most the distributions and embedded distros (via busybox)
              – Sudarshan Srinivasan
              Feb 17 at 9:38













            up vote
            2
            down vote



            accepted







            up vote
            2
            down vote



            accepted






            The net-tools package was deprecated for some time, being replaced by iproute2 (ip being the primary tool in that package). Many distributions no longer even ship net-tools as part of their base install.



            Development of net-tools has since restarted, but this has resulted in a number of the tools being enhanced in compatibility breaking ways, as you've seen with ifconfig. From NEWS.Debian.gz on a Debian 9.0 system:




            After 15 years without upstream development, net-tools is being worked on again, fixing many long-standing issues.
            The bad news is that the output of many commands has changed, and it is sure to break scripts that relied on parsing it.




            For that reason it may be an idea to adapt your scripts to use the iproute2 tools. For example, ip link should give you similar information to your bare ifconfig above. The one downside to this approach is that it breaks compatibility with non-Linux systems, almost all of which use ifconfig.






            share|improve this answer














            The net-tools package was deprecated for some time, being replaced by iproute2 (ip being the primary tool in that package). Many distributions no longer even ship net-tools as part of their base install.



            Development of net-tools has since restarted, but this has resulted in a number of the tools being enhanced in compatibility breaking ways, as you've seen with ifconfig. From NEWS.Debian.gz on a Debian 9.0 system:




            After 15 years without upstream development, net-tools is being worked on again, fixing many long-standing issues.
            The bad news is that the output of many commands has changed, and it is sure to break scripts that relied on parsing it.




            For that reason it may be an idea to adapt your scripts to use the iproute2 tools. For example, ip link should give you similar information to your bare ifconfig above. The one downside to this approach is that it breaks compatibility with non-Linux systems, almost all of which use ifconfig.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 29 '17 at 10:49

























            answered Nov 29 '17 at 9:13









            mjturner

            3,8781224




            3,8781224











            • Thanks iproute2 looks to be supported on most the distributions and embedded distros (via busybox)
              – Sudarshan Srinivasan
              Feb 17 at 9:38

















            • Thanks iproute2 looks to be supported on most the distributions and embedded distros (via busybox)
              – Sudarshan Srinivasan
              Feb 17 at 9:38
















            Thanks iproute2 looks to be supported on most the distributions and embedded distros (via busybox)
            – Sudarshan Srinivasan
            Feb 17 at 9:38





            Thanks iproute2 looks to be supported on most the distributions and embedded distros (via busybox)
            – Sudarshan Srinivasan
            Feb 17 at 9:38













            up vote
            1
            down vote













            An alternative way to list all interfaces in Linux from shell is reading /proc/net/dev, which have a more stable format than the output of ifconfig(8) from net-tools.



            For example, to get name of interfaces:



            whr@debianjessie:~$ sed -r -e 1,2d -e 's/^ +//' -e 's/: .+//' /proc/net/dev
            ppp0
            lo
            eth0
            eth1





            share|improve this answer


























              up vote
              1
              down vote













              An alternative way to list all interfaces in Linux from shell is reading /proc/net/dev, which have a more stable format than the output of ifconfig(8) from net-tools.



              For example, to get name of interfaces:



              whr@debianjessie:~$ sed -r -e 1,2d -e 's/^ +//' -e 's/: .+//' /proc/net/dev
              ppp0
              lo
              eth0
              eth1





              share|improve this answer
























                up vote
                1
                down vote










                up vote
                1
                down vote









                An alternative way to list all interfaces in Linux from shell is reading /proc/net/dev, which have a more stable format than the output of ifconfig(8) from net-tools.



                For example, to get name of interfaces:



                whr@debianjessie:~$ sed -r -e 1,2d -e 's/^ +//' -e 's/: .+//' /proc/net/dev
                ppp0
                lo
                eth0
                eth1





                share|improve this answer














                An alternative way to list all interfaces in Linux from shell is reading /proc/net/dev, which have a more stable format than the output of ifconfig(8) from net-tools.



                For example, to get name of interfaces:



                whr@debianjessie:~$ sed -r -e 1,2d -e 's/^ +//' -e 's/: .+//' /proc/net/dev
                ppp0
                lo
                eth0
                eth1






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 29 '17 at 19:05









                GAD3R

                22.6k154894




                22.6k154894










                answered Nov 29 '17 at 17:34









                Low power

                264




                264



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407637%2fto-overcome-differences-in-format-of-ifconfig-ubuntu16-04-and-ubuntu17-01%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay