Can someone explain the concept of the terms interface
vs device
andin OpenWrt?
I have been searching for tutorials for openwrt internet configurations and I have some doubts about the concept of "interface" vd "device":
- From /sys/class/net I got 10 "devices" as follows:
and I compared these with the Network -- Interfaces section:
From the above we can see that now here're 4 interfaces and each of them is mapped with a device.
Then I clicked "Edit" and there's a configuration page:
and I assume that this page is used for mapping an interface (interface VPN, for example) with a device. However, in this page, there're only 7 devices but there're 10 devices in /sys/class/net. So my first doubt is: Why there're some missing devices ? (I know that lo is loopback so it should be excluded, but why other devices like wlan0 is missing? and what are the tun0, ipsec0 which are not listed in /sys/class/net?)
Then I used ifconfig command and the following are the listed devices:
root@OpenWrt:~# ifconfig
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)
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:3011159 errors:0 dropped:5 overruns:0 frame:0
TX packets:2682309 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1869685252 (1.7 GiB) TX bytes:1717196202 (1.5 GiB)
Interrupt:30
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:726368 errors:0 dropped:0 overruns:0 frame:0
TX packets:726368 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:177122201 (168.9 MiB) TX bytes:177122201 (168.9 MiB)
wlan0 Link encap:Ethernet HWaddr FC:7C:02:E9:6A:52
inet6 addr: fe80::fe7c:2ff:fee9:6a52/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:8533 (8.3 KiB)
why there're only 4 devices and why wlan0 appears?(while there's no wlan0 at interface configuration page)
then I used command ip addr
and the results are as follows:
root@OpenWrt:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
3: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN group default qlen 1000
link/tunnel6 :: brd :: permaddr de43:1794:da45::
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether fc:7c:02:e9:6a:53 brd ff:ff:ff:ff:ff:ff
inet 192.168.31.3/24 brd 192.168.31.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::fe7c:2ff:fee9:6a53/64 scope link
valid_lft forever preferred_lft forever
5: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether e2:e0:32:72:28:da brd ff:ff:ff:ff:ff:ff
6: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default qlen 1000
link/gre 0.0.0.0 brd 0.0.0.0
7: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
8: erspan0@NONE: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
9: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fc:7c:02:e9:6a:52 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fe7c:2ff:fee9:6a52/64 scope link
valid_lft forever preferred_lft forever
16: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:7a:4f:68:6c brd ff:ff:ff:ff:ff:ff
inet 172.31.0.1/24 brd 172.31.0.255 scope global docker0
valid_lft forever preferred_lft forever
In sum, all the above configurations seems incoherent and I am confused about the logic in them.
As for the Concept of Interfaces vs Devices:
- What is their purpose?
- What is their relation?
- How do they play together?
- And Additionally, what is the purpose of br-lan? (I think it is a combination of a series of interfaces organized by switch, but I can't imagine how these interfaces work as a br-lan)
I appreciate if anyone could clear some of the doubts that I have. Thank you.