最近想搞搞AP和AC,这玩意在商用市场还是很有用途的!以前简单的把外网线插入lan口,关闭dhcp的方式不够好,如果想产品化还需要修改很多!
把我折腾的步骤发出来吧!
简易模式
1、将br-lan接口的dhcp服务关闭
进入“网络”->“接口”,点击“Lan”的“修改按钮”
提交应用
2、将外网线插入LAN口内
3、完成
缺点:路由器本身无法联网,仅仅是一种临时的方案,无法联网也就无法发现并与ac通讯
桥接AP模式
参考官方的WIKI:http://wiki.openwrt.org/doc/recipes/bridgedap
1、将br-lan的协议设置为dhcp(如果知道IP,也可以设置为静态)
1 2 3 4 5 6 7 8 9 10 |
config interface 'lan' option ifname 'eth2.1' option type 'bridge' option proto 'dhcp' #option proto 'static' #option ipaddr '192.168.0.121' #option netmask '255.255.255.0' #option gateway '192.168.0.1' #option dns '192.168.0.1' option macaddr '00:01:42:60:3d:3c' |
2、将外网线插入lan口内
3、重启网络
1 |
/etc/init.d/network restart |
这时候ifconfig就可以看到br-lan获取到了上级的ip地址
1 2 3 4 5 6 7 8 |
root@ayongwifi:/etc/config# ifconfig br-lan Link encap:Ethernet HWaddr 00:01:42:60:3D:3C inet addr:192.168.0.120 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3310 errors:0 dropped:1057 overruns:0 frame:0 TX packets:905 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:338708 (330.7 KiB) TX bytes:329149 (321.4 KiB) |
ping外网也是通的
1 2 3 4 5 6 7 8 9 |
root@ayongwifi:/etc/config# ping baidu.com PING baidu.com (123.125.114.144): 56 data bytes 64 bytes from 123.125.114.144: seq=0 ttl=55 time=24.713 ms 64 bytes from 123.125.114.144: seq=1 ttl=55 time=24.012 ms ^C --- baidu.com ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 24.012/24.362/24.713 ms root@ayongwifi:/etc/config# |
设置管理口
如果这时候将br-lan的防火墙设置为不可从外网访问,那么ap就没有管理界面了,就只能靠AC来下发配置!
想要增加管理口,就要让br-lan有个特殊的地址,PC直接接入lan口,设置pc的ip为静态,并设置与ap相同的子网掩码
就可以让PC直接访问AP的管理界面
在/etc/config/network中添加alias
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
root@ayongwifi:/etc/config# cat network config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config interface 'lan' option ifname 'eth2.1' option type 'bridge' option proto 'dhcp' #option ipaddr '192.168.0.121' #option netmask '255.255.255.0' #option gateway '192.168.0.1' #option dns '192.168.0.1' option macaddr '00:01:42:60:3d:3c' config interface 'wan' option ifname 'eth2.2' option proto 'dhcp' option macaddr '00:01:42:60:3d:3d' config 'alias' ###添加br-lan的second ip option 'interface' 'lan' option 'proto' 'static' option 'ipaddr' '10.0.0.7' option 'netmask' '255.255.255.0' root@ayongwifi:/etc/config# |
将pc的ip设置为10.0.0.100,子网掩码为255.255.255.0,就可以直接访问http://10.0.0.7进入ap的管理界面了!
为了防止内网中也有同样的地址,可以添加多个alias,防止出现冲突现象,不过也不用多虑,因为当你要进入管理界面时需要连网线插入lan口,而ap一般都只有一个网口,所以也就不会有冲突。
关于alias的官方WIKI:http://wiki.openwrt.org/doc/uci/network#aliases
最后关闭dnsmasq的自启动(其实关不关无所谓!)
1 |
/etc/init.d/dnsmasq disable |
路由AP混合模式
路由AP模式也是一种特殊的,说的简单点就是,一部分接入的为路由模式,一部分接入的为AP模式
是路由模式与AP模式的混合体,如下拓扑图示意
有线端获取到的地址为路由器的内网地址1.x网段,通过wifi连接的客户端获取到的为上级路由器2.x网段ip
其实如果路由器支持交换机划分端口,可以设置某几个网口与wifi绑定桥接,作为AP模式,另几个网口为路由模式
实际上在实际产品中这种模式会让人混淆,虽然作用确实不错,但是真正产品化的东西还是不用这样的!
参考官方WIKI:http://wiki.openwrt.org/doc/recipes/routedap
纯AP模式
官方的wiki上还提到一种纯AP模式,叫做dumb ap模式,其实与第一个讲的网桥AP没多大区别,直接看官方的WIKI
http://wiki.openwrt.org/doc/recipes/dumbap
本篇文章重点学习借鉴:
http://lvii.github.io/network/2013/06/24/tp-link-wr703n-openwrt-bridged-ap-mode/
感谢哥们。。。。