After days of studying, I got more confused about "device" and "interface" concepts. I found some explanations about the network configuration seems to be contradicted in these two concepts:
- /sys/class/net
From sysfs man page, this file represents networking devices:
Thus, I listed all the networking devices of my openwrt(phicomm n1 as host) as follows:
- ipconfig command
From ifconfig(8) - Linux manual page (man7.org), ipconfig command displays the status of the currently active interfaces:
By executing ipconfig -a command, I listed all interfaces:
root@OpenWrt:~# ifconfig -a
docker0 Link encap:Ethernet HWaddr 02:42:7A:4F:68:6C
inet addr:172.31.0.1 Bcast:172.31.0.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
dummy0 Link encap:Ethernet HWaddr E2:E0:32:72:28:DA
BROADCAST NOARP MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
erspan0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1450 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth0 Link encap:Ethernet HWaddr FC:7C:02:E9:6A:53
inet addr:192.168.31.3 Bcast:192.168.31.255 Mask:255.255.255.0
inet6 addr: fe80::fe7c:2ff:fee9:6a53/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5263667 errors:0 dropped:5 overruns:0 frame:0
TX packets:4156935 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3277095525 (3.0 GiB) TX bytes:2835687763 (2.6 GiB)
Interrupt:30
gre0 Link encap:UNSPEC HWaddr 00-00-00-00-FF-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:1476 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
gretap0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
BROADCAST MULTICAST MTU:1462 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ip6tnl0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:1452 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:897389 errors:0 dropped:0 overruns:0 frame:0
TX packets:897389 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:404757065 (386.0 MiB) TX bytes:404757065 (386.0 MiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr FC:7C:02:E9:6A:52
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:9322 (9.1 KiB)
As you can see, all these "interfaces " are actually "devices" in /sys/class/net file.
Also, the above interfaces contradicts with the configuration webpage of interface:
From this screenshot, the interfaces are VPN0, DOCKER, VPN, LAN, while docker0, etho, etc. are actually devices.
So how do we tell from device and interface? I saw that some one said that device is layer2 and interface is layer3, is that correct? and if so, how is the relationship between layer2 and layer3, can they be mapped randomly ?
I appreciate that you can clear my doubts. Thank you