一个小型的无线路由器 Linux 系统OpenWRT

2026/1/19 14:36:25

nvram unset dr_lan_rx

4. nvram commit

当你对 NVRAM 做了一大堆修改后,你需要把这些修改保存起来,否则你的路由器 RESET 后,这些修改便没有了,和上面一样,这时你要执行:

nvram commit

1. WRT54G 的网络概况

下面是 WRT54G 的内部结构示意图:

WRT54G由包括LAN,WAN,WIFI 等 3 部份组成,相等于图中的vlan0,vlan1,eth0。

http://www.eosp.org/wp-content/photo...chitecture.png

当你安装好 OpenWrt 后,NVRAM 里的默认配置是这样的:

lan_ifname=br0

lan_ifnames=”vlan0 eth1” lan_proto=static

lan_ipaddr=192.168.1.1 lan_netmask=255.255.255.0

wan_ifname=vlan1 wan_proto=dhcp

第 1 项 lan_ifname=br0 是指 LAN 的网络介面名称; 第 2 项 lan_ifnames=”vlan0 eth1” 是指实际上 LAN 的真正网络介面,这里包括 vlan0(Port 1-4) 和 eth1 (无线网卡接口) ;

第 3 项 lan_proto=static 是指 LAN 用固定 IP 方式;

第 4 项 lan_ipaddr=192.168.1.1 指定了 LAN 的 IP 是 192.168.1.1; 第 5 项 lan_netmask=255.255.255.0 指定了 LAN 的子网络掩码;

第 6 项 wan_ifname=vlan1 指定了 WAN 的网络为 vlan1 (Port 0); 第 7 项 wan_proto=dhcp 指定了 WAN 的网络方式为 DHCP;

2. 配置 Lan 网络参数

假设我想修改路由器的 TCP/IP 设定为:

IP: 192.168.0.1

掩码: 255.255.255.0 网关: 192.168.0.254

DNS1: 192.168.0.254

DNS2: 202.14.67.4

并打开 DHCP 服务,IP 范围由 192.168.0.100 至 192.168.0.150;可以执行以下命令:

nvram set lan_proto=static

nvram set lan_ipaddr=192.168.0.1 nvram set lan_netmask=255.255.255.0 nvram set lan_gateway=192.168.0.254 nvram set lan_dns=’192.168.0.254 202.14.67.4’

nvram set dhcp_start=100 nvram set dhcp_num=50 nvram commit reboot

第 1 项 nvram set lan_proto=static 是指 LAN 的网络方式为固定 IP

第 2 项 nvram set lan_ipaddr=192.168.0.1 是指定 LAN 的 IP 地址为 192.168.0.1

第 3 项 nvram set lan_netmask=255.255.255.0 是指定 LAN 的子网络掩码为 255.255.255.0 第 4 项 nvram set lan_gateway=192.168.0.254 是指定 LAN 的网关为 192.168.0.254 第 5 项 nvram set lan_dns=’192.168.0.254 202.14.67.4’ 是指定 LAN 使的 DNS 服务器,由于DNS服务器有 2 个,所以用空格来分开。

第 6 项 nvram set dhcp_start=100 是指 DHCP 服务器从 192.168.0.100 开始派发 IP 第 7 项 nvram set dhcp_num=50 是指 DHCP 从 192.168.0.100 开始 派发到 192.168.0.150 (100+50) 为止。

3. 设定WAN

一般常见的上网方式有3种: DHCP, PPPOE 拨号上网 及 STATIC IP(固定 IP)

2.1 DHCP

DHCP很简单,你只需告诉路由器用DHCP来上网,它便会替你自动取得IP,网络掩码,网关,DNS等资料

nvram set wan_proto=dhcp nvram commit reboot

2.2 固定 IP

很多商用宽带都是使用固定 IP,ISP 会提供 IP 地址(第2项),子网络掩码(第3项),网关(第4项)及DNS(第5项)资料,DNS如果超过一个的话用空格分开。

nvram set wan_proto=static

nvram set wan_ipaddr=218.103.124.24 nvram set wan_netmask=255.255.255.252 nvram set wan_gateway=218.103.124.23 nvram set wan_dns=’210.80.60.1 210.80.60.2’ nvram commit reboot

2.3 PPPOE

PPPOE 在家用宽带是很常见的,ISP会提供 用户名及密码,你只需把下面第5和第6项换成相应的用户名及密码就可以用PPPOE上网了。

nvram set wan_ifname=ppp0 nvram set wan_proto=pppoe

nvram set ppp_mtu=1492

nvram set pppoe_ifname=vlan1

nvram set ppp_username=your_isp_login nvram set ppp_passwd=your_isp_password nvram commit

reboot

第 1 项 nvram set wan_ifname=ppp0 是指 WAN 使用 ppp0 网络介面来拨号上网 第 2 项 nvram set wan_proto=pppoe 是指 WAN 使用 PPPOE 的方式上网 第 3 项 nvram set ppp_mtu=1492 指定 MTU 为 1492

第 4 项 nvram set pppoe_ifname=vlan1 指 PPPOE 拨号的介面是 vlan1

第 5 项 nvram set ppp_username=your_isp_login 指定PPPOE 的用户名是 your_isp_login 第 6 项 nvram set ppp_passwd=your_isp_password 指定了 PPPOE 的密码是 your_isp_password

4. 配置无线网络

nvram set wl0_gmode= nvram set wl0_ssid= nvram set wl0_channel= nvram set wl0_closed= nvram commit wifi up

关闭 WEP 和 WPA

nvram set wl0_wep=disabled nvram set wl0_akm=open

开启WEP

nvram set wl0_wep= nvram set wl0_wep_bit= nvram set wl0_key= nvram set wl0_key1= nvram set wl0_key2= nvram set wl0_key3= nvram set wl0_key4=

nvram set security_mode_last=wep nvram commit ifdown wifi ifup wifi WPA

nvram unset wl0_auth_mode nvram set wl0_akm=psk nvram set wl0_crypto= nvram set wl0_wpa_psk= nvram set wl0_radius_key= nvram set wl0_radius_ipaddr= nvram set wl0_radius_port= nvram set security_mode_last=wpa nvram commit

无线网络 – MAC Filter

nvram set wl0_macmode=allow nvram set wl0_mac_list= nvram set wl0_mac_deny= nvram commit wifi up

5. 加强 OpenWrt 的安全性

我认为没有密码和使用 Telnet 是不安全的,OpenWrt 在设定密码后会把 Telnet 关闭,改用 SSH 服务


一个小型的无线路由器 Linux 系统OpenWRT.doc 将本文的Word文档下载到电脑
搜索更多关于: 一个小型的无线路由器 Linux 系统OpenWRT 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219