OpenWRT-Document中文

本文档详细介绍了OpenWRT路由器的配置与开发,包括安装、初始化配置、网络和无线网络设置,以及构建系统、增加平台支持和调试方法。内容涵盖静态路由、交换机配置、IPv6连接、无线网络的Atheros、Broadcom和mac80211驱动的配置。同时,讲解了如何使用build系统构建和创建包,以及如何处理二进制驱动和固件格式。
摘要由CSDN通过智能技术生成

内容

第一节
路由器

1.1 开始


1.1.1 安装


1.1.2 初始化配置


1.1.3 Failsafe mode


1.2 配置OpenWrt


1.2.1 网络

Kamikaze 中的网络配置信息储存在 /etc/config/network 文件中,并且各个接口都有自己的配置。每个接口的配置直接关联到一个eth或者wifi接口(eth0, wl0, ..) ,或者桥接到多个接口。像下面这样:


ifname定义了特殊的Linux接口。如果你想桥接到一个或者多个接口,设置 ifname 为一个接口列表,并添加:

可以通过简单的加入VLAN ID号标记来使用VLAN,例如eth0.1。这样就可以了。

这里对eth0.proto有一个简单的静态配置来描述该接口所使用的协议,默认的Image中通常会提供'none' 'static', 'dhcp''pppoe'方式。其他方式,可以通过加载包来安装其他协议。

像例子中这样使用'static'方法时,ipaddr和netmask是强制的,gateway和dns是可选的。你可以指定不止一个的DNS server,用空格分开。

DHCP目前只可以设置ipaddr(希望从server请求的IP地址)和hostname(客户端主机名标签),两者都是可选的。PPP协议族接受如下选项:

基于PPP 的协议(pppoe, pptp, ...) 接受下列选项:

  • username
    The PPP username (usually with PAP authentication)
  • password
    The PPP password
  • keepalive
    Ping PPP server(使用LCP)。这个选项定义了重连前的失败ping最大个数。这个ping间隔默认为5,但是可以通过附加", " 来修改keepalive 值。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 be changed by appending ", " to the keepalive value
  • demand
    Use Dial on Demand (value specifies the maximum idle time.
  • server: (pptp)
    远程pptp server IP The remote pptp server IP

对于所有类型的协议,都可以通过设置mtu选项来设置MTU。

设置静态路由Setting up static routes

你可以给特定的接口设置静态路由,它将在该接口被配置以后显示出效果。

像下面这样简单的加入:

config route foo
option interface lan
option target 1.1.1.0
option netmask 255.255.255.0
option gateway 192.168.1.1

route段中的name是可选的,interface,target和gateway选项是强制的。不使用netmask选项将会使该route设置成host route。

The name for the route section is 可选的, the interface, targetand gateway options are mandatory. Leaving out the netmaskoption will turn the route into a host route.


设置交换(目前仅支持broadcom)Setting up the switch (currently broadcom only)

交换设置需要加入'switch'设置段。例如:

The switch configuration is set by adding a 'switch'config section. 例子:


在Broadcom的硬件上,段名称需要是eth0,所以交换驱动不能识别其他物理交换设备。每个vlan选项都要有个名字vlan , 是交换驱动中使用的VLAN序号。这些值可以取如下后缀:

VLANOn Broadcom hardware the section name needs to be eth0, as the switch driver does not detect the switch on any other physical device. Every vlan option needs to have the name vlan where is the VLAN number as used in the switch driver. As value it takes a list of ports with these 可选的 suffixes:

  • '*': 将当前VLAN设置成该端口的默认VLANSet the default VLAN (PVID) of the Port to the current VLAN
  • 'u': 强制该端口为非标记的Force the port to be untagged
  • 't': 强制该端口为标记的Force the port to be tagged

CPU的端口默认是标记的,其他所有端口为非标记。在Broadcom硬件上,CPU端口永远是5。其他端口可能会因不同的硬件而异。

The CPU port defaults to tagged, all other ports to untagged. On Broadcom hardware the CPU port is always 5. The other ports may vary with different hardware.

例如,如果你希望有3个vlan,3个端口用于交换,1个端口是DMZ(隔离区),另外一个端口是WAN口,可以使用如下配置:

For instance, if you wish to have 3 vlans, like one 3-port switch, 1 port in a DMZ, and another one as your WAN interface, use the following configuration :


交换层将会自动建立3个接口:eth0.0(vlan0), eth0.1(vlan1) and eth0.2(vlan2)。

Three interfaces will be automatically created using this switch layout : eth0.0(vlan0), eth0.1(vlan1) and eth0.2(vlan2). You can then assign those interfaces to a custom network configuration name like lan, wanor dmzfor instance.


Setting up IPv6 connectivity

OpenWrt supports IPv6 connectivity using PPP, Tunnel brokers or static assignment.

If you use PPP, IPv6 will be setup using IP6CP and there is nothing to configure.

To setup an IPv6 tunnel to a tunnel broker, you can install the 6scriptspackage and edit the /etc/config/6tunnelfile and change the settings accordingly :


  • 'tnlifname': Set the interface name of the IPv6 in IPv4 tunnel
  • 'remoteip4': IP address of the remote end to establish the 6in4 tunnel. This address is given by the tunnel broker
  • 'localip4': IP address of your router to establish the 6in4 tunnel. It will usually match your WAN IP address.
  • 'localip6': IPv6 address to setup on your tunnel side This address is given by the tunnel broker
  • 'prefix': IPv6 prefix to setup on the LAN.

Using the same package you can also setup an IPv6 bridged connection :


By default the script bridges the WAN interface with the LAN interface and uses ebtables to filter anything that is not IPv6 on the bridge.

IPv6 static addressing is also supported using a similar setup as IPv4 but with the ip6prefixing (when applicable).



1.2.2 无线网络Wireless

WiFi设置储存在/etc/config/wireless中(目前支持Broadcom, Atheros 和mac80211)。当第一次启动路由器时,将会自动检测你的卡并且创建简单的配置文件。默认情况下 'option network lan' 是被注释掉的。它提供了一个非安全的无线网络共享。

The WiFi settings are configured in the file /etc/config/wireless(currently supported on Broadcom, Atheros and mac80211). When booting the router for the first time it should detect your card and create a sample configuration file. By default 'option network lan' is commented. This prevents unsecured sharing of the network over the wireless interface.

每一个无线驱动都有自己的配置脚本/lib/wifi/driver_name.sh ,用来处理驱动选项和配置。这个脚本也调用特殊二进制,例如Broadcom的w1c,或者atheros的hostapd 和wpa_supplicant 。

Each wireless driver has its own configuration script in /lib/wifi/driver_name.sh which handles driver specific options and configurations. This script is also calling driver specific binaries like wlc for Broadcom, or hostapd and wpa_supplicant for atheros.

使用不同的架构配置是因为不同的驱动配置。

The reason for using such architecture, is that it abstracts the driver configuration.

标准的Broadcom无线配置: Generic Broadcom wireless config:

标准的Atheros无线配置: Generic Atheros wireless config:

标准的mac80211无线配置: Generic mac80211 wireless config:

标准的多播Atheros无线配置: Generic multi-radio Atheros wireless config:

这个文件里有两个类型的配置段。wifi-device针对物理wifi接口,wifi-iface配置了一个在wifi-device之上的虚拟接口(需要被驱动支持)。

There are two types of config sections in this file. The 'wifi-device' refers to the physical wifi interface and 'wifi-iface' configures a virtual interface on top of that (if supported by the driver).

无线配置全概括:A full outline of the wireless configuration file with description of each field:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值