Reprinted in: https://blog.csdn.net/u012041204/article/details/53674946
1. Basic Concepts
LAN: The English abbreviation of Local Area Network, that is,
the connection between our computer and the router in the local area network is connected to this port.WAN: The English abbreviation of Wide Area Network, that is, the network cable pulled in by the WAN
operator is connected to this port.The Chinese name of VLAN (Virtual Local Area Network) is "Virtual Local Area Network". A
VLAN is usually logically divided into several network segments in the local area network to form a VLAN. A local area network can be divided into N multiple VLANs, so that the VLANs cannot communicate with each other (usually for security reasons). Both LAN and WAN belong to VLAN
2. Configure WAN port and LAN port
First download the OpenWRT system to the development board (RT5350), then power on the development board into the OpenWRT system, and use secureCRT for command operations. (secureCRT should be so easy for those familiar with Linux embedded development)
The configuration file in OpenWRT is under /etc/config/, and the configuration of WAN and LAN is in /etc/config/network The
above is the screenshot after opening the fileAnalyze the information in the above file (only the key points):
config interface 'lan' //Configure the LAN port
option type 'bridge' //Bridge mode
option ifname 'eth0.1' // Represents vlan1, this is very important, the following configuration Will use
option proto 'static' //Static IPconfig device 'lan_dev' //Configure LAN hardware information
option macaddr //Set MAC addressconfig interface 'wan' //Configure WAN port
option type 'dhcp' //dhcp mode (dhcp self-Baidu)config switch //switch means switch in Chinese, so the following is to enable vlan port
option enable_vlan '1' // 1 means to open vlan portconfig switch_vlan
option vlan '1' //VLAN1, matches the option ifname 'eth0.1' above, so configure the LAN port
option ports '0 1 2 3 6t' //0~3 are all LAN ports, RT5350 has 5 portsconfig switch_vlan
option vlan '2' //VLAN2, matches the option ifname 'eth0.2' above, so configure the WAN port
option ports '4 6t' //4 is the WAN port
Well, through the above introduction, you should be able to configure the port as a LAN port or a WAN port at will.
The above network file is the UCI configuration file. For in-depth study, you can go to https://wiki.openwrt.org/doc/uci