Under Openwrt\trunk\target\linux\ramips\base-files\etc\uci-defaults\02_network, the settings for the network are indicated
The following script is called: \openwrt\trunk\package\base-files\files\lib
. /lib/functions.sh------->openwrt\trunk\package\base-files\files\lib\functions.sh
. /lib/ramips.sh------->openwrt\trunk\target\linux\ramips\base-files\lib\ramips.sh
. /lib/functions/uci-defaults.sh---------->openwrt\trunk\package\base-files\files\lib\functions\ uci-defaults.sh setting up the network:
<pre name= "code" class= "CPP" >ucidef_set_interface_lan () {
local ifname=$1
UCI batch <<eof
Set network.lan= ' interface '
set network.lan.ifname= ' $ifname '
set network.lan.force_link=1
set Network.lan.type= ' Bridge '
set network.lan.proto= ' static '
set network.lan.ipaddr= ' 192.168.1.1 '
set network.lan.netmask= ' 255.255.255.0 '
set network.lan.ip6assign= '
EOF
}
If you want to add a gateway, as follows:
Set network.lan.gateway= ' 192.168.1.254 '
set network.lan.dns= ' 8.8.8.8 '
Here, Eth0.proto has a simple static configuration to describe the protocol used by the interface, and the default image usually provides ' none ', ' Static ', ' DHCP ' and ' PPPoE ' mode. Other ways, you can install additional protocols by loading packages.
When using the ' static ' method as in this example, IPADDR and netmask are mandatory, and gateway and DNS are optional. You can specify more than one DNS server, separated by a space.
DHCP can now only set ipaddr (the IP address that you want to request from the server) and hostname (the client hostname tag), both of which are optional. The PPP protocol family accepts the following options:
PPP-based protocol (PPPoE, PPTP, ...) accepts the following options: username
The PPP username (usually with PAP authentication) password
The PPP password keepalive
Ping PPP Server (using LCP). This option defines the maximum number of failed pings before a re-connect. This ping interval defaults to 5, but you can modify the KeepAlive value by attaching ",". Ping the PPP server (using LCP). The value of this option specifies the maximum number of failed pings before reconnecting. The ping interval defaults to 5, but can is changed by appending "," to the KeepAlive value demand
Use Dial on Demand (value specifies the maximum idle time. Server: (PPTP)
Remote PPTP server IP The remotely PPTP server IP
For all types of protocols, you can set the MTU by setting the MTU option. set static routes setting up static routes
You can set a static route for a specific interface, which will show the effect after the interface is configured.
Join as simple as the following:
Config Route foo
Option interface LAN
Option Target 1.1.1.0
Option Netmask 255.255.255.0
Option Gateway 192.168.1.1
The name in the route segment is optional, and the Interface,target and gateway options are mandatory. Not using the netmask option will cause the route to be set to the host route.
The name for the route sections is optional, the interface, Targetand gateway options are mandatory. Leaving out the netmaskoption would turn the route into a host route.
Set up the WAN:
Ucidef_set_interface_wan () {
local ifname=$1
UCI batch <<eof
set network.wan= ' interface '
set Network.wan.ifname= ' $ifname '
set network.wan.proto= ' DHCP '
set network.wan6= ' interface '
set Network.wan6.ifname= ' @wan '
set network.wan6.proto= ' DHCPv6 '
EOF
}
So the RT5350 network settings are as follows:
Ramips_setup_interfaces under the Openwrt\trunk\target\linux\ramips\base-files\etc\uci-defaults\02_network file:
*)
rt3x5x= ' cat/proc/cpuinfo | egrep "(rt3.5| RT5350) "'
if [-N ' ${rt3x5x} ']; then
Ramips_setup_rt3x5x_vlans
else
Ucidef_set_interfaces_lan_wan" eth0.1 "" eth0.2 "
fi
;
Ramips_setup_rt3x5x_vlans ()
{
if [!-x/sbin/swconfig]; then
# legacy Default
Ucidef_set_interfaces_ Lan_wan "eth0.1" "eth0.2"
return
fi
local wanports= "
local lanports=" "for
Port in 5 4 3 2 1 0; Do
if [' Swconfig dev rt305x port $port get Disable ' = "1"]; Then
continue
fi
if [' Swconfig dev rt305x port $port get lan ' = "0"], then
wanports= "$port $wanports "
Else
lanports=" $port $lanports "
fi
done
Ucidef_set_interfaces_lan_wan" eth0.1 "" eth0.2 "
ucidef_add_switch" rt305x "" 1 "" 1 "
Ucidef_add_switch_vlan" rt305x "" 1 "" $lanports 6t "
ucidef_add_ Switch_vlan "rt305x" "2" "$wanports 6t"
}
rt5350)
Ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
ucidef_add_switch "Switch0" "1" "1"
ucidef_add_ Switch_vlan "Switch0" "1" "0 1 2 3 6t"
Ucidef_add_switch_vlan "Switch0" "2" "4 6t"
;;
As can be seen from the default configuration, ports 0, 1, 2, 3 belong to Vlan0, Port 4 belongs to Vlan1, and line 2nd indicates that the VLAN0 is set
is LAN, ports 0, 1, 2, 3 are LANs, and line 10th indicates that the VLAN1 is set to Wan, and Port 4 is WAN.
Option Ports ' 0 1 2 3 6t ' because the Board Development Board only applies VLAN port 3 and Port 4
The 0,1,2 of this line is removed, so that a two VLAN is configured, Port 3 as the first VLAN, and Port 4 as the 2nd VLAN, so that the network ring
The environment is well-equipped. Port 3 is a LAN and Port 4 is a WAN.