openwrt中br-lan,eth0,eth0.1,eth0.2


openwrt中br-lan,eth0,eth0.1,eth0.2

來源 https://blog.phpgao.com/openwrt-interface.html

 

openwrt的接口真是多,老高一下子都看暈了,不過仔細理一理,還是能夠分辨的。

首先盜openwrt-wiki中的一張圖,這張圖對理解這些接口很重要!

網絡配置

有線網配置

openwrt的有線網絡配置文件位於/etc/config/network,老高的配置如下:

config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config globals 'globals' option ula_prefix 'auto' config interface 'lan' option ifname 'eth0.1' option force_link '1' option type 'bridge' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' option ip6assign '60' option macaddr '64:09:80:05:e1:bb' config interface 'wan' option ifname 'eth0.2' option _orig_ifname 'eth0.2' option _orig_bridge 'false' option proto 'pppoe' option macaddr '64:09:80:05:e1:bc' option username '11100026295' option password '380926' config interface 'wan6' option _orig_ifname '@wan' option _orig_bridge 'false' option proto '6to4' config switch option name 'mt762x' option reset '1' option enable_vlan '1' config switch_vlan option device 'mt762x' option vlan '1' option ports '0 1 2 3 5 6t' config switch_vlan option device 'mt762x' option vlan '2' option ports '4 6t'

無線網絡配置

openwrt的無線網絡配置文件位於/etc/config/wireless,老高的配置如下:

config wifi-device 'rai0' option type 'mt7612' option mode '14' option channel 'auto' option txpower '100' option ht '20+40+80' option country 'US' option disabled '0' config wifi-iface option device 'rai0' option network 'lan' option mode 'ap' option ssid 'BYBY_WORLD' option encryption 'psk2' option key 'xxx' config wifi-device 'ra0' option type 'rt2860v2' option mode '9' option channel 'auto' option txpower '100' option ht '40' option country 'US' option disabled '0' config wifi-iface option device 'ra0' option network 'lan' option mode 'ap' option wps 'pbc' option ssid 'HELLO_WORLD' option encryption 'psk2' option key 'xxx'

整理和搜索

乍一看老高都暈了,真么多啊!趕緊Google之,看有沒有什么發現!

交換機手冊(Switch Documentation)

Linux 網絡接口(Network Interfaces)

讀完這兩篇文章后貌似有所覺悟,先記下來理一理!

pppoe-wan

虛擬設備,他就是常見的撥號寬帶上網,需要有ISP提供的用戶名密碼,連接后方可激此接口!

lo

虛擬設備,自身的回環網設備。

ra0 rai0

這兩個是成對出現,一看就知道是無線設備,它們各自對應一個SSID,分別是2.4G和5G。

虛擬局域網

開啟虛擬局域網

對應 config switch

划分子網

你可以在網絡->交換機中找到!

對照着圖下面的配置應該很容易就懂了。

config switch_vlan option device 'mt762x' option vlan '1' option ports '0 1 2 3 5 6t' config switch_vlan option device 'mt762x' option vlan '2' option ports '4 6t'

eth0

eth0是一塊物理網卡。eth0.1 eth0.2都是從此設備上虛擬出來的。

eth0.1 是vlan 1分出的lan口。

eth0.2 是vlan 2分出的wan口。

br-lan

虛擬設備,用於LAN口設備橋接,可以用brctl show查看使用情況。

~ brctl show bridge name bridge id STP enabled interfaces br-lan 7fff.64098005e1bb no eth0.1 rai0 ra0

br-lan = eth0.1 + rai0 + ra0,即將有線LAN口和無線網統一划分為 LAN,便於管理!

更多資料

 

=====================

 

root@OpenWrt:~# cat /etc/os-release 
NAME="OpenWrt"
VERSION="18.06.1"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 18.06.1"
VERSION_ID="18.06.1"
HOME_URL="http://openwrt.org/"
BUG_URL="http://bugs.openwrt.org/"
SUPPORT_URL="http://forum.lede-project.org/"
BUILD_ID="r1026-811894e1"
LEDE_BOARD="ar71xx/nand"
LEDE_ARCH="mips_24kc"
LEDE_TAINTS="no-all"
LEDE_DEVICE_MANUFACTURER="OpenWrt"
LEDE_DEVICE_MANUFACTURER_URL="http://openwrt.org/"
LEDE_DEVICE_PRODUCT="Generic"
LEDE_DEVICE_REVISION="v0"
LEDE_RELEASE="OpenWrt 18.06.1 r1026-811894e1"
root@OpenWrt:~# 
root@OpenWrt:~# uname -a
Linux OpenWrt 4.9.138 #0 Fri Nov 30 14:52:43 2018 mips GNU/Linux
root@OpenWrt:~# 
root@OpenWrt:~# cat /proc/cpuinfo 
system type		: Qualcomm Atheros QCA9558 ver 1 rev 0
machine			: DomyWifi DW33D
processor		: 0
cpu model		: MIPS 74Kc V5.0
BogoMIPS		: 358.80
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16 dsp dsp2
shadow register sets	: 1
kscratch registers	: 0
package			: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

root@OpenWrt:~# 
root@OpenWrt:~# cat /proc/meminfo 
MemTotal:         254944 kB
MemFree:          199480 kB
MemAvailable:     190436 kB
Buffers:            9688 kB
Cached:            18344 kB
SwapCached:            0 kB
Active:            19992 kB
Inactive:          10012 kB
Active(anon):       2752 kB
Inactive(anon):      256 kB
Active(file):      17240 kB
Inactive(file):     9756 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          1980 kB
Mapped:             3272 kB
Shmem:              1036 kB
Slab:              10564 kB
SReclaimable:       4060 kB
SUnreclaim:         6504 kB
KernelStack:         480 kB
PageTables:          336 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      127472 kB
Committed_AS:       6960 kB
VmallocTotal:    1048372 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
root@OpenWrt:~# 
root@OpenWrt:~# cat /proc/partitions 
major minor  #blocks  name

  31        0        256 mtdblock0
  31        1         64 mtdblock1
  31        2      14528 mtdblock2
  31        3       5312 mtdblock3
  31        4       1472 mtdblock4
  31        5         64 mtdblock5
  31        6      16000 mtdblock6
  31        7      98304 mtdblock7
  31        8      32768 mtdblock8
   8        0   15558144 sda
   8        1   15554048 sda1
root@OpenWrt:~# 
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 9.0M      9.0M         0 100% /rom
tmpfs                   124.5M      1.0M    123.5M   1% /tmp
/dev/mtdblock3            5.2M    432.0K      4.8M   8% /overlay
overlayfs:/overlay        5.2M    432.0K      4.8M   8% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1                14.8G     64.0K     14.8G   0% /mnt/sda1
/dev/mtdblock6            9.0M      9.0M         0 100% /mnt/mtdblock6
root@OpenWrt:~# 
root@OpenWrt:~# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00e30000 00010000 "rootfs"
mtd3: 00530000 00010000 "rootfs_data"
mtd4: 00170000 00010000 "kernel"
mtd5: 00010000 00010000 "art"
mtd6: 00fa0000 00010000 "firmware"
mtd7: 06000000 00020000 "rootfs_data"
mtd8: 02000000 00020000 "backup"
root@OpenWrt:~# 
root@OpenWrt:~# 
root@OpenWrt:~# dmesg | grep spi
[    0.000000] Kernel command line:  board=DW33D mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware);ar934x-nfc:96m(rootfs_data),32m(backup)ro console=ttyS0,115200 rootfstype=squashfs noinitrd
[    0.893783] m25p80 spi0.0: found mx25l12805d, expected m25p80
[    0.900057] m25p80 spi0.0: mx25l12805d (16384 Kbytes)
[    0.905208] 6 cmdlinepart partitions found on MTD device spi0.0
[    0.911238] Creating 6 MTD partitions on "spi0.0":
root@OpenWrt:~# 
root@OpenWrt:~# dmesg | grep Clocks
[    0.000000] Clocks: CPU:720.000MHz, DDR:600.000MHz, AHB:200.000MHz, Ref:40.000MHz
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/config/network 

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fdfd:dcb6:dfdc::/48'

config interface 'lan'
	option type 'bridge'
	option ifname 'eth1.1'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.11.1'

config interface 'wan'
	option ifname 'eth0.2'
	option proto 'dhcp'

config interface 'wan6'
	option ifname 'eth0.2'
	option proto 'dhcpv6'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '2 3 4 5 6t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '1 0t'

root@OpenWrt:~# 
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/config/wireless 

config wifi-device 'radio0'
	option type 'mac80211'
	option channel '36'
	option hwmode '11a'
	option path 'pci0000:00/0000:00:00.0'
	option htmode 'VHT80'
	option country 'US'
	option legacy_rates '1'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option ssid 'DW33D-5G'
	option encryption 'psk2'
	option key 'lsgxwifilink'

config wifi-device 'radio1'
	option type 'mac80211'
	option channel '11'
	option hwmode '11g'
	option path 'platform/qca955x_wmac'
	option htmode 'HT20'
	option country 'US'
	option legacy_rates '1'

config wifi-iface 'default_radio1'
	option device 'radio1'
	option network 'lan'
	option mode 'ap'
	option ssid 'DW33D-24G'
	option encryption 'psk2'
	option key 'lsgxwifilink'

root@OpenWrt:~# 
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/config/firewall 

config defaults
	option syn_flood '1'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'REJECT'

config zone
	option name 'lan'
	list network 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'

config zone
	option name 'wan'
	list network 'wan'
	list network 'wan6'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'

config forwarding
	option src 'lan'
	option dest 'wan'

config rule
	option name 'Allow-DHCP-Renew'
	option src 'wan'
	option proto 'udp'
	option dest_port '68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-Ping'
	option src 'wan'
	option proto 'icmp'
	option icmp_type 'echo-request'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IGMP'
	option src 'wan'
	option proto 'igmp'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-DHCPv6'
	option src 'wan'
	option proto 'udp'
	option src_ip 'fc00::/6'
	option dest_ip 'fc00::/6'
	option dest_port '546'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-MLD'
	option src 'wan'
	option proto 'icmp'
	option src_ip 'fe80::/10'
	list icmp_type '130/0'
	list icmp_type '131/0'
	list icmp_type '132/0'
	list icmp_type '143/0'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Input'
	option src 'wan'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	list icmp_type 'router-solicitation'
	list icmp_type 'neighbour-solicitation'
	list icmp_type 'router-advertisement'
	list icmp_type 'neighbour-advertisement'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Forward'
	option src 'wan'
	option dest '*'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-IPSec-ESP'
	option src 'wan'
	option dest 'lan'
	option proto 'esp'
	option target 'ACCEPT'

config rule
	option name 'Allow-ISAKMP'
	option src 'wan'
	option dest 'lan'
	option dest_port '500'
	option proto 'udp'
	option target 'ACCEPT'

config include
	option path '/etc/firewall.user'

config include 'miniupnpd'
	option type 'script'
	option path '/usr/share/miniupnpd/firewall.include'
	option family 'any'
	option reload '1'

config include 'adbyby'
	option type 'script'
	option path '/usr/share/adbyby/firewall.include'
	option reload '1'

config rule 'kms'
	option name 'kms'
	option target 'ACCEPT'
	option src 'wan'
	option proto 'tcp'
	option dest_port '1688'

config include 'shadowsocksr'
	option type 'script'
	option path '/var/etc/shadowsocksr.include'
	option reload '1'

config include 'wrtbwmon'
	option type 'script'
	option path '/etc/wrtbwmon.include'
	option reload '1'

config include 'pptpd'
	option type 'script'
	option path '/etc/pptpd.include'
	option reload '1'

config rule 'pptp'
	option name 'pptp'
	option target 'ACCEPT'
	option src 'wan'
	option proto 'tcp'
	option dest_port '1723'

config rule 'gre'
	option name 'gre'
	option target 'ACCEPT'
	option src 'wan'
	option proto '47'

root@OpenWrt:~# 
root@OpenWrt:~# 
root@OpenWrt:~# cat /etc/config/dhcp 

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option nonegcache '0'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.auto'
	option nonwildcard '1'
	option localservice '1'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '24h'
	option force '1'
	option ra 'server'
	option dhcpv6 'server'
	option ra_management '1'
	option ra_default '1'

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

root@OpenWrt:~# 
root@OpenWrt:~# ifconfig 
br-lan    Link encap:Ethernet  HWaddr 14:3D:F2:CB:9A:DD  
          inet addr:192.168.11.1  Bcast:192.168.11.255  Mask:255.255.255.0
          inet6 addr: fe80::163d:f2ff:fecb:9add/64 Scope:Link
          inet6 addr: fdfd:dcb6:dfdc::1/60 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3790087 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6492932 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1301078776 (1.2 GiB)  TX bytes:6703438607 (6.2 GiB)

eth0      Link encap:Ethernet  HWaddr 14:3D:F2:CB:9A:DE  
          inet6 addr: fe80::163d:f2ff:fecb:9ade/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7156095 errors:0 dropped:0 overruns:75 frame:0
          TX packets:4787213 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2503390857 (2.3 GiB)  TX bytes:1442610380 (1.3 GiB)
          Interrupt:4 

eth0.2    Link encap:Ethernet  HWaddr 14:3D:F2:CB:9A:DE  
          inet addr:192.168.1.7  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::163d:f2ff:fecb:9ade/64 Scope:Link
          inet6 addr: fe80::163d:f2ff:fecb:9ade/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7156071 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4787198 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6669546570 (6.2 GiB)  TX bytes:1423460094 (1.3 GiB)

eth1      Link encap:Ethernet  HWaddr 14:3D:F2:CB:9A:DD  
          inet6 addr: fe80::163d:f2ff:fecb:9add/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34693 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:3854512 (3.6 MiB)
          Interrupt:5 

eth1.1    Link encap:Ethernet  HWaddr 14:3D:F2:CB:9A:DD  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34685 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:3714764 (3.5 MiB)

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:2466 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2466 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:196065 (191.4 KiB)  TX bytes:196065 (191.4 KiB)

wlan0     Link encap:Ethernet  HWaddr 14:3D:F2:CB:9A:DF  
          inet6 addr: fe80::163d:f2ff:fecb:9adf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4411547 errors:0 dropped:33393 overruns:0 frame:0
          TX packets:6527097 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1391076302 (1.2 GiB)  TX bytes:6837481031 (6.3 GiB)

wlan1     Link encap:Ethernet  HWaddr 14:3D:F2:CB:9A:DC  
          inet6 addr: fe80::163d:f2ff:fecb:9adc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34682 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:4338526 (4.1 MiB)

root@OpenWrt:~# 
root@OpenWrt:~# 
root@OpenWrt:~# brctl show
bridge name	bridge id		STP enabled	interfaces
br-lan		7fff.143df2cb9add	no		eth1.1
							wlan0
							wlan1
root@OpenWrt:~# 
root@OpenWrt:~# arp -a
IP address       HW type     Flags       HW address            Mask     Device
192.168.1.79     0x1         0x2         a4:4e:31:97:aa:b4     *        br-lan
10.0.100.79      0x1         0x2         a4:4e:31:97:aa:b4     *        br-lan
192.168.11.168   0x1         0x2         a4:4e:31:97:aa:b4     *        br-lan
192.168.1.1      0x1         0x2         fc:f2:9f:a6:8c:78     *        eth0.2
192.168.1.79     0x1         0x0         00:00:00:00:00:00     *        eth0.2
root@OpenWrt:~# 
root@OpenWrt:~# route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0.2
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0.2
192.168.11.0    *               255.255.255.0   U     0      0        0 br-lan
root@OpenWrt:~# 
root@OpenWrt:~# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0.2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0.2
192.168.11.0    0.0.0.0         255.255.255.0   U         0 0          0 br-lan
root@OpenWrt:~# 

 

============== End

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM