OpenWRT network configuration WAN port and LAN port

Reprinted in: https://blog.csdn.net/u012041204/article/details/53674946


1. Basic Concepts

  1. 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.

  2. WAN: The English abbreviation of Wide Area Network, that is, the network cable pulled in by the WAN 
    operator is connected to this port.

  3. 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

  1. 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)

  2. The configuration file in OpenWRT is under /etc/config/, and the configuration of WAN and LAN is in /etc/config/network The 
    write picture description here 
    above is the screenshot after opening the file

  3. Analyze 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 IP

    config device 'lan_dev' //Configure LAN hardware information 
    option macaddr //Set MAC address

    config 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 port

    config 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 ports

    config 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324684895&siteId=291194637