How to find name of currently-active network interface?





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







4















I need to get the name of the network interface (e.g. eth0, wlan0) that is the currently-active one, the one sending and receiving traffic at the moment. When it's connected to WiFi, it would be wlan0 but when it's connected directly it would be eth0. Or something else, depending on the network devices on the system and which one is active. How can I find this out?










share|improve this question





























    4















    I need to get the name of the network interface (e.g. eth0, wlan0) that is the currently-active one, the one sending and receiving traffic at the moment. When it's connected to WiFi, it would be wlan0 but when it's connected directly it would be eth0. Or something else, depending on the network devices on the system and which one is active. How can I find this out?










    share|improve this question

























      4












      4








      4








      I need to get the name of the network interface (e.g. eth0, wlan0) that is the currently-active one, the one sending and receiving traffic at the moment. When it's connected to WiFi, it would be wlan0 but when it's connected directly it would be eth0. Or something else, depending on the network devices on the system and which one is active. How can I find this out?










      share|improve this question














      I need to get the name of the network interface (e.g. eth0, wlan0) that is the currently-active one, the one sending and receiving traffic at the moment. When it's connected to WiFi, it would be wlan0 but when it's connected directly it would be eth0. Or something else, depending on the network devices on the system and which one is active. How can I find this out?







      wireless networking internet network-manager ethernet






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 14 '14 at 18:30









      user779159user779159

      2162513




      2162513






















          4 Answers
          4






          active

          oldest

          votes


















          7














          Open a terminal and run the command:



          ifconfig


          The active interface will have an IP address and transmitted and received bytes. Here is an example:



          eth0  Link encap:Ethernet  HWaddr xx:a8:6b:fe:06:xx
          inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
          inet6 addr: fe80::eea8:6bff:fefe:696/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:449232 errors:0 dropped:0 overruns:0 frame:0
          TX packets:309483 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:633900275 (633.9 MB) TX bytes:27944824 (27.9 MB)


          Check if the ethernet interface is used:



          ping -c3 -I eth0 www.google.com
          ping: Warning: source address might be selected on device other than eth0.
          PING www.google.com (74.125.228.145) from 192.168.1.100 eth0: 56(84) bytes of data.Wi-Fi
          From Think410 (192.168.1.100) icmp_seq=1 Destination Host Unreachable
          From Think410 (192.168.1.100) icmp_seq=2 Destination Host Unreachable
          From Think410 (192.168.1.100) icmp_seq=3 Destination Host Unreachable


          Verify that the wireless interface is used:



          ping -c3 -I wlan0 www.google.com
          PING www.google.com (74.125.228.148) from 192.168.1.100 wlan0: 56(84) bytes of data.
          64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=1 ttl=50 time=37.5 ms
          64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=2 ttl=50 time=36.8 ms
          64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=3 ttl=50 time=35.9 ms


          So, obviously, internet traffic is currently routed through wlan0, my wireless interface.



          It is possible to have both ethernet and wireless connected simultaneously. Normally, Network Manager will disallow it, preferring ethernet over wireless because it is generally faster and more secure. If one wanted to use ethernet for the LAN and wireless for the WAN (internet), one would typically remove NM and set all the details manually in /etc/network/interfaces.






          share|improve this answer


























          • In my system I see a large number of RX and TX packets for both eth0 and wlan0. I guess these numbers are not cleared when switching between wired/wireless networks? So I can't use that to tell. However, inet addr only appears for the one I'm currently connected to, so that looks like that could work. However, couldn't there be times when both show an IP? Like if I'm connected by a cable to another device but WiFi is to the internet? Is there a way to tell which of the 2 is sending you online?

            – user779159
            Jan 14 '14 at 21:01











          • Please see my edit.

            – chili555
            Jan 14 '14 at 21:19



















          4














          No need for ping to hunt-and-peck. Use ip link; it has more germane info than ifconfig. Each interface will report something like




          • LOOPBACK, meaning active but never goes external (wired or wireless)

          • NO-CARRIER, meaning external but no signal being generated

          • BROADCAST, meaning external and is active

          • LOWER-UP, meaning PHY is enabled


          You can have two or more external interfaces with LOWER-UP but generally a bad idea. Here's my laptop with loopback (notice LOWER_UP), down ethernet, wlan0 up and generating a signal, wlan4 (USB wifi) UP but NOT generating a signal, wlan4.mon monitor mode sniffing all stations on BSS (notice LOWER-UP). wlan4.mon does not transmit.



          1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
          link/ether 24:b6:fd:24:59:b9 brd ff:ff:ff:ff:ff:ff
          3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
          link/ether 4c:eb:42:32:0c:9e brd ff:ff:ff:ff:ff:ff
          26: wlan4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
          link/ether 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ff
          27: wlan4.mon: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000
          link/ieee802.11/radiotap 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ffter code here





          share|improve this answer

































            2














            A good way to figure out the interface where particular traffic would go is to use ip route get Just use say Google (8.8.8.8) or Cloudflare (1.1.1.1) DNS servers to figure out which interface internet traffic would go through:



            $ ip route get 1.1.1.1
            1.1.1.1 via 192.168.2.1 dev eth0 src 192.168.2.155 uid 0
            cache


            Then you can do stuff like set a variable with the interface that is used for internet:



            LANIFACE=$(ip route get 1.1.1.1 | grep -Po '(?<=devs)w+' | cut -f1 -d ' ')


            Then you can also get the IP address of the interface:



            LANIP=$(ip addr show "$LANIFACE" | grep "inet " | cut -d '/' -f1 | cut -d ' ' -f6)





            share|improve this answer































              1














              If you want a little more detail try jnettop this tool shows you detailed traffic monitoring in the terminal.



              sudo apt-get install jnettop



              once installed simply type jnettop in the terminal






              share|improve this answer
























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                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: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                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%2faskubuntu.com%2fquestions%2f405508%2fhow-to-find-name-of-currently-active-network-interface%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                7














                Open a terminal and run the command:



                ifconfig


                The active interface will have an IP address and transmitted and received bytes. Here is an example:



                eth0  Link encap:Ethernet  HWaddr xx:a8:6b:fe:06:xx
                inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
                inet6 addr: fe80::eea8:6bff:fefe:696/64 Scope:Link
                UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
                RX packets:449232 errors:0 dropped:0 overruns:0 frame:0
                TX packets:309483 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:633900275 (633.9 MB) TX bytes:27944824 (27.9 MB)


                Check if the ethernet interface is used:



                ping -c3 -I eth0 www.google.com
                ping: Warning: source address might be selected on device other than eth0.
                PING www.google.com (74.125.228.145) from 192.168.1.100 eth0: 56(84) bytes of data.Wi-Fi
                From Think410 (192.168.1.100) icmp_seq=1 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=2 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=3 Destination Host Unreachable


                Verify that the wireless interface is used:



                ping -c3 -I wlan0 www.google.com
                PING www.google.com (74.125.228.148) from 192.168.1.100 wlan0: 56(84) bytes of data.
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=1 ttl=50 time=37.5 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=2 ttl=50 time=36.8 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=3 ttl=50 time=35.9 ms


                So, obviously, internet traffic is currently routed through wlan0, my wireless interface.



                It is possible to have both ethernet and wireless connected simultaneously. Normally, Network Manager will disallow it, preferring ethernet over wireless because it is generally faster and more secure. If one wanted to use ethernet for the LAN and wireless for the WAN (internet), one would typically remove NM and set all the details manually in /etc/network/interfaces.






                share|improve this answer


























                • In my system I see a large number of RX and TX packets for both eth0 and wlan0. I guess these numbers are not cleared when switching between wired/wireless networks? So I can't use that to tell. However, inet addr only appears for the one I'm currently connected to, so that looks like that could work. However, couldn't there be times when both show an IP? Like if I'm connected by a cable to another device but WiFi is to the internet? Is there a way to tell which of the 2 is sending you online?

                  – user779159
                  Jan 14 '14 at 21:01











                • Please see my edit.

                  – chili555
                  Jan 14 '14 at 21:19
















                7














                Open a terminal and run the command:



                ifconfig


                The active interface will have an IP address and transmitted and received bytes. Here is an example:



                eth0  Link encap:Ethernet  HWaddr xx:a8:6b:fe:06:xx
                inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
                inet6 addr: fe80::eea8:6bff:fefe:696/64 Scope:Link
                UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
                RX packets:449232 errors:0 dropped:0 overruns:0 frame:0
                TX packets:309483 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:633900275 (633.9 MB) TX bytes:27944824 (27.9 MB)


                Check if the ethernet interface is used:



                ping -c3 -I eth0 www.google.com
                ping: Warning: source address might be selected on device other than eth0.
                PING www.google.com (74.125.228.145) from 192.168.1.100 eth0: 56(84) bytes of data.Wi-Fi
                From Think410 (192.168.1.100) icmp_seq=1 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=2 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=3 Destination Host Unreachable


                Verify that the wireless interface is used:



                ping -c3 -I wlan0 www.google.com
                PING www.google.com (74.125.228.148) from 192.168.1.100 wlan0: 56(84) bytes of data.
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=1 ttl=50 time=37.5 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=2 ttl=50 time=36.8 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=3 ttl=50 time=35.9 ms


                So, obviously, internet traffic is currently routed through wlan0, my wireless interface.



                It is possible to have both ethernet and wireless connected simultaneously. Normally, Network Manager will disallow it, preferring ethernet over wireless because it is generally faster and more secure. If one wanted to use ethernet for the LAN and wireless for the WAN (internet), one would typically remove NM and set all the details manually in /etc/network/interfaces.






                share|improve this answer


























                • In my system I see a large number of RX and TX packets for both eth0 and wlan0. I guess these numbers are not cleared when switching between wired/wireless networks? So I can't use that to tell. However, inet addr only appears for the one I'm currently connected to, so that looks like that could work. However, couldn't there be times when both show an IP? Like if I'm connected by a cable to another device but WiFi is to the internet? Is there a way to tell which of the 2 is sending you online?

                  – user779159
                  Jan 14 '14 at 21:01











                • Please see my edit.

                  – chili555
                  Jan 14 '14 at 21:19














                7












                7








                7







                Open a terminal and run the command:



                ifconfig


                The active interface will have an IP address and transmitted and received bytes. Here is an example:



                eth0  Link encap:Ethernet  HWaddr xx:a8:6b:fe:06:xx
                inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
                inet6 addr: fe80::eea8:6bff:fefe:696/64 Scope:Link
                UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
                RX packets:449232 errors:0 dropped:0 overruns:0 frame:0
                TX packets:309483 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:633900275 (633.9 MB) TX bytes:27944824 (27.9 MB)


                Check if the ethernet interface is used:



                ping -c3 -I eth0 www.google.com
                ping: Warning: source address might be selected on device other than eth0.
                PING www.google.com (74.125.228.145) from 192.168.1.100 eth0: 56(84) bytes of data.Wi-Fi
                From Think410 (192.168.1.100) icmp_seq=1 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=2 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=3 Destination Host Unreachable


                Verify that the wireless interface is used:



                ping -c3 -I wlan0 www.google.com
                PING www.google.com (74.125.228.148) from 192.168.1.100 wlan0: 56(84) bytes of data.
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=1 ttl=50 time=37.5 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=2 ttl=50 time=36.8 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=3 ttl=50 time=35.9 ms


                So, obviously, internet traffic is currently routed through wlan0, my wireless interface.



                It is possible to have both ethernet and wireless connected simultaneously. Normally, Network Manager will disallow it, preferring ethernet over wireless because it is generally faster and more secure. If one wanted to use ethernet for the LAN and wireless for the WAN (internet), one would typically remove NM and set all the details manually in /etc/network/interfaces.






                share|improve this answer















                Open a terminal and run the command:



                ifconfig


                The active interface will have an IP address and transmitted and received bytes. Here is an example:



                eth0  Link encap:Ethernet  HWaddr xx:a8:6b:fe:06:xx
                inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
                inet6 addr: fe80::eea8:6bff:fefe:696/64 Scope:Link
                UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
                RX packets:449232 errors:0 dropped:0 overruns:0 frame:0
                TX packets:309483 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:633900275 (633.9 MB) TX bytes:27944824 (27.9 MB)


                Check if the ethernet interface is used:



                ping -c3 -I eth0 www.google.com
                ping: Warning: source address might be selected on device other than eth0.
                PING www.google.com (74.125.228.145) from 192.168.1.100 eth0: 56(84) bytes of data.Wi-Fi
                From Think410 (192.168.1.100) icmp_seq=1 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=2 Destination Host Unreachable
                From Think410 (192.168.1.100) icmp_seq=3 Destination Host Unreachable


                Verify that the wireless interface is used:



                ping -c3 -I wlan0 www.google.com
                PING www.google.com (74.125.228.148) from 192.168.1.100 wlan0: 56(84) bytes of data.
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=1 ttl=50 time=37.5 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=2 ttl=50 time=36.8 ms
                64 bytes from iad23s17-in-f20.1e100.net (74.125.228.148): icmp_seq=3 ttl=50 time=35.9 ms


                So, obviously, internet traffic is currently routed through wlan0, my wireless interface.



                It is possible to have both ethernet and wireless connected simultaneously. Normally, Network Manager will disallow it, preferring ethernet over wireless because it is generally faster and more secure. If one wanted to use ethernet for the LAN and wireless for the WAN (internet), one would typically remove NM and set all the details manually in /etc/network/interfaces.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 18 '15 at 4:57









                rwarvi

                93




                93










                answered Jan 14 '14 at 18:39









                chili555chili555

                39.2k55281




                39.2k55281













                • In my system I see a large number of RX and TX packets for both eth0 and wlan0. I guess these numbers are not cleared when switching between wired/wireless networks? So I can't use that to tell. However, inet addr only appears for the one I'm currently connected to, so that looks like that could work. However, couldn't there be times when both show an IP? Like if I'm connected by a cable to another device but WiFi is to the internet? Is there a way to tell which of the 2 is sending you online?

                  – user779159
                  Jan 14 '14 at 21:01











                • Please see my edit.

                  – chili555
                  Jan 14 '14 at 21:19



















                • In my system I see a large number of RX and TX packets for both eth0 and wlan0. I guess these numbers are not cleared when switching between wired/wireless networks? So I can't use that to tell. However, inet addr only appears for the one I'm currently connected to, so that looks like that could work. However, couldn't there be times when both show an IP? Like if I'm connected by a cable to another device but WiFi is to the internet? Is there a way to tell which of the 2 is sending you online?

                  – user779159
                  Jan 14 '14 at 21:01











                • Please see my edit.

                  – chili555
                  Jan 14 '14 at 21:19

















                In my system I see a large number of RX and TX packets for both eth0 and wlan0. I guess these numbers are not cleared when switching between wired/wireless networks? So I can't use that to tell. However, inet addr only appears for the one I'm currently connected to, so that looks like that could work. However, couldn't there be times when both show an IP? Like if I'm connected by a cable to another device but WiFi is to the internet? Is there a way to tell which of the 2 is sending you online?

                – user779159
                Jan 14 '14 at 21:01





                In my system I see a large number of RX and TX packets for both eth0 and wlan0. I guess these numbers are not cleared when switching between wired/wireless networks? So I can't use that to tell. However, inet addr only appears for the one I'm currently connected to, so that looks like that could work. However, couldn't there be times when both show an IP? Like if I'm connected by a cable to another device but WiFi is to the internet? Is there a way to tell which of the 2 is sending you online?

                – user779159
                Jan 14 '14 at 21:01













                Please see my edit.

                – chili555
                Jan 14 '14 at 21:19





                Please see my edit.

                – chili555
                Jan 14 '14 at 21:19













                4














                No need for ping to hunt-and-peck. Use ip link; it has more germane info than ifconfig. Each interface will report something like




                • LOOPBACK, meaning active but never goes external (wired or wireless)

                • NO-CARRIER, meaning external but no signal being generated

                • BROADCAST, meaning external and is active

                • LOWER-UP, meaning PHY is enabled


                You can have two or more external interfaces with LOWER-UP but generally a bad idea. Here's my laptop with loopback (notice LOWER_UP), down ethernet, wlan0 up and generating a signal, wlan4 (USB wifi) UP but NOT generating a signal, wlan4.mon monitor mode sniffing all stations on BSS (notice LOWER-UP). wlan4.mon does not transmit.



                1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
                link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
                2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
                link/ether 24:b6:fd:24:59:b9 brd ff:ff:ff:ff:ff:ff
                3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
                link/ether 4c:eb:42:32:0c:9e brd ff:ff:ff:ff:ff:ff
                26: wlan4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
                link/ether 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ff
                27: wlan4.mon: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000
                link/ieee802.11/radiotap 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ffter code here





                share|improve this answer






























                  4














                  No need for ping to hunt-and-peck. Use ip link; it has more germane info than ifconfig. Each interface will report something like




                  • LOOPBACK, meaning active but never goes external (wired or wireless)

                  • NO-CARRIER, meaning external but no signal being generated

                  • BROADCAST, meaning external and is active

                  • LOWER-UP, meaning PHY is enabled


                  You can have two or more external interfaces with LOWER-UP but generally a bad idea. Here's my laptop with loopback (notice LOWER_UP), down ethernet, wlan0 up and generating a signal, wlan4 (USB wifi) UP but NOT generating a signal, wlan4.mon monitor mode sniffing all stations on BSS (notice LOWER-UP). wlan4.mon does not transmit.



                  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
                  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
                  2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
                  link/ether 24:b6:fd:24:59:b9 brd ff:ff:ff:ff:ff:ff
                  3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
                  link/ether 4c:eb:42:32:0c:9e brd ff:ff:ff:ff:ff:ff
                  26: wlan4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
                  link/ether 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ff
                  27: wlan4.mon: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000
                  link/ieee802.11/radiotap 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ffter code here





                  share|improve this answer




























                    4












                    4








                    4







                    No need for ping to hunt-and-peck. Use ip link; it has more germane info than ifconfig. Each interface will report something like




                    • LOOPBACK, meaning active but never goes external (wired or wireless)

                    • NO-CARRIER, meaning external but no signal being generated

                    • BROADCAST, meaning external and is active

                    • LOWER-UP, meaning PHY is enabled


                    You can have two or more external interfaces with LOWER-UP but generally a bad idea. Here's my laptop with loopback (notice LOWER_UP), down ethernet, wlan0 up and generating a signal, wlan4 (USB wifi) UP but NOT generating a signal, wlan4.mon monitor mode sniffing all stations on BSS (notice LOWER-UP). wlan4.mon does not transmit.



                    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
                    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
                    2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
                    link/ether 24:b6:fd:24:59:b9 brd ff:ff:ff:ff:ff:ff
                    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
                    link/ether 4c:eb:42:32:0c:9e brd ff:ff:ff:ff:ff:ff
                    26: wlan4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
                    link/ether 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ff
                    27: wlan4.mon: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000
                    link/ieee802.11/radiotap 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ffter code here





                    share|improve this answer















                    No need for ping to hunt-and-peck. Use ip link; it has more germane info than ifconfig. Each interface will report something like




                    • LOOPBACK, meaning active but never goes external (wired or wireless)

                    • NO-CARRIER, meaning external but no signal being generated

                    • BROADCAST, meaning external and is active

                    • LOWER-UP, meaning PHY is enabled


                    You can have two or more external interfaces with LOWER-UP but generally a bad idea. Here's my laptop with loopback (notice LOWER_UP), down ethernet, wlan0 up and generating a signal, wlan4 (USB wifi) UP but NOT generating a signal, wlan4.mon monitor mode sniffing all stations on BSS (notice LOWER-UP). wlan4.mon does not transmit.



                    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
                    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
                    2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
                    link/ether 24:b6:fd:24:59:b9 brd ff:ff:ff:ff:ff:ff
                    3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
                    link/ether 4c:eb:42:32:0c:9e brd ff:ff:ff:ff:ff:ff
                    26: wlan4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
                    link/ether 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ff
                    27: wlan4.mon: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN qlen 1000
                    link/ieee802.11/radiotap 00:26:f2:b3:d7:93 brd ff:ff:ff:ff:ff:ffter code here






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Sep 3 '14 at 16:26

























                    answered Sep 3 '14 at 16:19









                    dturvenedturvene

                    1815




                    1815























                        2














                        A good way to figure out the interface where particular traffic would go is to use ip route get Just use say Google (8.8.8.8) or Cloudflare (1.1.1.1) DNS servers to figure out which interface internet traffic would go through:



                        $ ip route get 1.1.1.1
                        1.1.1.1 via 192.168.2.1 dev eth0 src 192.168.2.155 uid 0
                        cache


                        Then you can do stuff like set a variable with the interface that is used for internet:



                        LANIFACE=$(ip route get 1.1.1.1 | grep -Po '(?<=devs)w+' | cut -f1 -d ' ')


                        Then you can also get the IP address of the interface:



                        LANIP=$(ip addr show "$LANIFACE" | grep "inet " | cut -d '/' -f1 | cut -d ' ' -f6)





                        share|improve this answer




























                          2














                          A good way to figure out the interface where particular traffic would go is to use ip route get Just use say Google (8.8.8.8) or Cloudflare (1.1.1.1) DNS servers to figure out which interface internet traffic would go through:



                          $ ip route get 1.1.1.1
                          1.1.1.1 via 192.168.2.1 dev eth0 src 192.168.2.155 uid 0
                          cache


                          Then you can do stuff like set a variable with the interface that is used for internet:



                          LANIFACE=$(ip route get 1.1.1.1 | grep -Po '(?<=devs)w+' | cut -f1 -d ' ')


                          Then you can also get the IP address of the interface:



                          LANIP=$(ip addr show "$LANIFACE" | grep "inet " | cut -d '/' -f1 | cut -d ' ' -f6)





                          share|improve this answer


























                            2












                            2








                            2







                            A good way to figure out the interface where particular traffic would go is to use ip route get Just use say Google (8.8.8.8) or Cloudflare (1.1.1.1) DNS servers to figure out which interface internet traffic would go through:



                            $ ip route get 1.1.1.1
                            1.1.1.1 via 192.168.2.1 dev eth0 src 192.168.2.155 uid 0
                            cache


                            Then you can do stuff like set a variable with the interface that is used for internet:



                            LANIFACE=$(ip route get 1.1.1.1 | grep -Po '(?<=devs)w+' | cut -f1 -d ' ')


                            Then you can also get the IP address of the interface:



                            LANIP=$(ip addr show "$LANIFACE" | grep "inet " | cut -d '/' -f1 | cut -d ' ' -f6)





                            share|improve this answer













                            A good way to figure out the interface where particular traffic would go is to use ip route get Just use say Google (8.8.8.8) or Cloudflare (1.1.1.1) DNS servers to figure out which interface internet traffic would go through:



                            $ ip route get 1.1.1.1
                            1.1.1.1 via 192.168.2.1 dev eth0 src 192.168.2.155 uid 0
                            cache


                            Then you can do stuff like set a variable with the interface that is used for internet:



                            LANIFACE=$(ip route get 1.1.1.1 | grep -Po '(?<=devs)w+' | cut -f1 -d ' ')


                            Then you can also get the IP address of the interface:



                            LANIP=$(ip addr show "$LANIFACE" | grep "inet " | cut -d '/' -f1 | cut -d ' ' -f6)






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 8 '18 at 3:23









                            rkantosrkantos

                            212




                            212























                                1














                                If you want a little more detail try jnettop this tool shows you detailed traffic monitoring in the terminal.



                                sudo apt-get install jnettop



                                once installed simply type jnettop in the terminal






                                share|improve this answer




























                                  1














                                  If you want a little more detail try jnettop this tool shows you detailed traffic monitoring in the terminal.



                                  sudo apt-get install jnettop



                                  once installed simply type jnettop in the terminal






                                  share|improve this answer


























                                    1












                                    1








                                    1







                                    If you want a little more detail try jnettop this tool shows you detailed traffic monitoring in the terminal.



                                    sudo apt-get install jnettop



                                    once installed simply type jnettop in the terminal






                                    share|improve this answer













                                    If you want a little more detail try jnettop this tool shows you detailed traffic monitoring in the terminal.



                                    sudo apt-get install jnettop



                                    once installed simply type jnettop in the terminal







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jul 18 '15 at 5:23









                                    A1 ComputersA1 Computers

                                    1399




                                    1399






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • 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%2faskubuntu.com%2fquestions%2f405508%2fhow-to-find-name-of-currently-active-network-interface%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

                                        數位音樂下載

                                        When can things happen in Etherscan, such as the picture below?

                                        格利澤436b