Original: https://www.cnblogs.com/qianpangzi/p/10563979.html
View the current available network interfaces ubuntu system. Methods as below
-----------------------------------------------------------------------------------------
After we installed a Linux system is the most common task is to configure the network. Of course, you can configure the network interface when installing the system. However, for some people, they prefer to configure the network or change existing settings in the system before installing. As we all know, in order to configure the network settings on the command line, we must first know how many available network interfaces in the system there. This simple guide will list all possible ways to find an available network interfaces in Linux and Unix operating systems.
Find the available network interfaces in Linux
We can use these following methods to find the available network interfaces.
Method 1 using the ifconfig command
Use the command to view the network interface is still the method most commonly used. I believe there are many Linux users still use this method. ifconfig
$ ifconfig -a
Sample output:
enp5s0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 24:b6:fd:37:8b:29 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 171420 bytes 303980988 (289.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 171420 bytes 303980988 (289.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlp9s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.225.37 netmask 255.255.255.0 broadcast 192.168.225.255 inet6 2409:4072:6183:c604:c218:85ff:fe50:474f prefixlen 64 scopeid 0x0<global> inet6 fe80::c218:85ff:fe50:474f prefixlen 64 scopeid 0x20<link> ether c0:18:85:50:47:4f txqueuelen 1000 (Ethernet) RX packets 564574 bytes 628671925 (599.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 299706 bytes 60535732 (57.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
As shown in the above output, Linux on my machine has two network interfaces, which are called (the wired LAN board) and (wireless LAN). Which is the loopback network card, it is used to access the local network service, typically its IP address . enp5s0
wlp9s0
lo
127.0.0.1
We are also available in many variants such as FreeBSD UNIX using the same to list the available network cards. ifconfig
Method 2 using the command ip
In the latest version of Linux, the command has been deprecated. You can use the command to set out the network interface, as follows: ifconfig
ip
$ ip link show
Sample output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp5s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 24:b6:fd:37:8b:29 brd ff:ff:ff:ff:ff:ff 3: wlp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000 link/ether c0:18:85:50:47:4f brd ff:ff:ff:ff:ff:ff
You can also use the following command to view.
$ ip addr
$ ip -s link
Did you notice? These commands also shows connected state of the network interface. If you look carefully at the output of the above, you will notice that I did not follow the wired LAN network cable connection (from above in the output can be seen). Further, my wireless card has been connected (the output from the above it can be seen). Want to know more details, you can check out our previous guide to view the network interfaces in Linux connected state . DOWN
UP
These two commands ( ifconfig
and ) enough to see the available network card in your system, the LInux. ip
However, there are still other ways to list the Linux network interface, and then let's see.
Method 3 using / sys / class / net directory
Linux kernel network interface details stored in the directory, you can verify that the list of available interfaces and consistent with previous results by viewing the contents of this directory. /sys/class/net
$ ls /sys/class/net
Sample output:
enp5s0 lo wlp9s0
Method 4 using / proc / net / dev directory
In the Linux operating system, the file contains information about network interfaces. /proc/net/dev
To view the available network cards, simply use the following command to view the contents of the above file:
$ cat /proc/net/dev
Sample output:
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
wlp9s0: 629189631 566078 0 0 0 0 0 0 60822472 300922 0 0 0 0 0 0 enp5s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 lo: 303980988 171420 0 0 0 0 0 0 303980988 171420 0 0 0 0 0 0
Method 5 using the command netstat
netstat
Command can list a variety of information, such as network connections, routing tables, interface statistics, masquerade connections and multicast members and so on.
$ netstat -i
Sample output:
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
lo 65536 171420 0 0 0 171420 0 0 0 LRU wlp9s0 1500 565625 0 0 0 300543 0 0 0 BMRU
Please note was abandoned, alternative command . Also note that this method will only list active interfaces, rather than all available interfaces. netstat
netstat -i
ip -s link
Method 6 using the command nmcli
nmcli
NetworkManager is a command used to control and report on network status line tools. It can be used to create, display, edit, delete, activate, deactivate network connections and display network status.
If the NetworkManager your Linux system installed, you can use the following command to use the list of possible network interfaces: nmcli
$ nmcli device status
or
$ nmcli connection show
Now that you know how to find a method of network interfaces available in Linux
If you know of other quick way to find an available network interfaces in Linux, please share it in the comments section below, I will check your review and update this guide.
Original: https://www.cnblogs.com/qianpangzi/p/10563979.html
View the current available network interfaces ubuntu system. Methods as below
-----------------------------------------------------------------------------------------
After we installed a Linux system is the most common task is to configure the network. Of course, you can configure the network interface when installing the system. However, for some people, they prefer to configure the network or change existing settings in the system before installing. As we all know, in order to configure the network settings on the command line, we must first know how many available network interfaces in the system there. This simple guide will list all possible ways to find an available network interfaces in Linux and Unix operating systems.
Find the available network interfaces in Linux
We can use these following methods to find the available network interfaces.
Method 1 using the ifconfig command
Use the command to view the network interface is still the method most commonly used. I believe there are many Linux users still use this method. ifconfig
$ ifconfig -a
Sample output:
enp5s0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 24:b6:fd:37:8b:29 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 171420 bytes 303980988 (289.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 171420 bytes 303980988 (289.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlp9s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.225.37 netmask 255.255.255.0 broadcast 192.168.225.255 inet6 2409:4072:6183:c604:c218:85ff:fe50:474f prefixlen 64 scopeid 0x0<global> inet6 fe80::c218:85ff:fe50:474f prefixlen 64 scopeid 0x20<link> ether c0:18:85:50:47:4f txqueuelen 1000 (Ethernet) RX packets 564574 bytes 628671925 (599.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 299706 bytes 60535732 (57.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
As shown in the above output, Linux on my machine has two network interfaces, which are called (the wired LAN board) and (wireless LAN). Which is the loopback network card, it is used to access the local network service, typically its IP address . enp5s0
wlp9s0
lo
127.0.0.1
We are also available in many variants such as FreeBSD UNIX using the same to list the available network cards. ifconfig
Method 2 using the command ip
In the latest version of Linux, the command has been deprecated. You can use the command to set out the network interface, as follows: ifconfig
ip
$ ip link show
Sample output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp5s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 24:b6:fd:37:8b:29 brd ff:ff:ff:ff:ff:ff 3: wlp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000 link/ether c0:18:85:50:47:4f brd ff:ff:ff:ff:ff:ff
You can also use the following command to view.
$ ip addr
$ ip -s link
Did you notice? These commands also shows connected state of the network interface. If you look carefully at the output of the above, you will notice that I did not follow the wired LAN network cable connection (from above in the output can be seen). Further, my wireless card has been connected (the output from the above it can be seen). Want to know more details, you can check out our previous guide to view the network interfaces in Linux connected state . DOWN
UP
These two commands ( ifconfig
and ) enough to see the available network card in your system, the LInux. ip
However, there are still other ways to list the Linux network interface, and then let's see.
Method 3 using / sys / class / net directory
Linux kernel network interface details stored in the directory, you can verify that the list of available interfaces and consistent with previous results by viewing the contents of this directory. /sys/class/net
$ ls /sys/class/net
Sample output:
enp5s0 lo wlp9s0
Method 4 using / proc / net / dev directory
In the Linux operating system, the file contains information about network interfaces. /proc/net/dev
To view the available network cards, simply use the following command to view the contents of the above file:
$ cat /proc/net/dev
Sample output:
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
wlp9s0: 629189631 566078 0 0 0 0 0 0 60822472 300922 0 0 0 0 0 0 enp5s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 lo: 303980988 171420 0 0 0 0 0 0 303980988 171420 0 0 0 0 0 0
Method 5 using the command netstat
netstat
Command can list a variety of information, such as network connections, routing tables, interface statistics, masquerade connections and multicast members and so on.
$ netstat -i
Sample output:
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
lo 65536 171420 0 0 0 171420 0 0 0 LRU wlp9s0 1500 565625 0 0 0 300543 0 0 0 BMRU
Please note was abandoned, alternative command . Also note that this method will only list active interfaces, rather than all available interfaces. netstat
netstat -i
ip -s link
Method 6 using the command nmcli
nmcli
NetworkManager is a command used to control and report on network status line tools. It can be used to create, display, edit, delete, activate, deactivate network connections and display network status.
If the NetworkManager your Linux system installed, you can use the following command to use the list of possible network interfaces: nmcli
$ nmcli device status
or
$ nmcli connection show
Now that you know how to find a method of network interfaces available in Linux
If you know of other quick way to find an available network interfaces in Linux, please share it in the comments section below, I will check your review and update this guide.