Openwrt开发之wifi ap设置

Posted weishengzhong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Openwrt开发之wifi ap设置相关的知识,希望对你有一定的参考价值。

拓扑结构:

Wan口接外网或者上级router,lan口和wlan同属一个局域网;

配置/etc/config/wireless文件

config wifi-device radio0
        option type mac80211
        option path platform/10300000.wmac
        option htmode HT20
        option disabled 0
        option txpower 0
        option hwmode 11g
        option channel 11

config wifi-iface default_radio0
        option device radio0
        option network lan
        option mode ap
        option encryption none
        option ssid OpenWrt

接着修改/etc/config/network文件

config interface loopback
        option ifname lo
        option proto static
        option ipaddr 127.0.0.1
        option netmask 255.0.0.0

config globals globals
        option ula_prefix fd3d:25cc:a776::/48

config interface wan
        option ifname eth0.1
        option proto static
        option ipaddr 192.168.2.238
        option netmask 255.255.255.0
        option gateway 192.168.2.1
        option dns 114.114.114.114

config device wan_dev
        option name eth0.1
        option macaddr 00:0c:43:06:76:2a

config interface wan6
        option ifname eth0.1
        option proto dhcpv6

config interface lan
        option type bridge
        option ifname eth0.2
        option proto static
        option ipaddr 192.168.10.1
        option netmask 255.255.255.0
        option dns 114.114.114.114

config device lan_dev
        option name eth0.2
        option macaddr 00:0c:43:06:76:29

config switch
        option name switch0
        option reset 1
        option enable_vlan 1

config switch_vlan
        option device switch0
        option vlan 1
        option ports 0 6t

config switch_vlan
        option device switch0
        option vlan 2
        option ports 1 2 3 4 6t

然后重启network

/etc/init.d/network restart

测试发现如果开机关闭防火墙,则wifi不可访问外网,需要打开防火墙,在rc.local内加入开机启动防火墙

/etc/init.d/firewall start &
exit 0

如果打开防火墙后外网还是无法访问,可以修改防火墙规则 /etc/config/firewall

config zone
        option name             lan
        list   network          lan
        option input            ACCEPT
        option output           ACCEPT
        option forward          ACCEPT

config zone
        option name             wan
        list   network          wan
        list   network          wan6
        option input            REJECT
        option output           ACCEPT
        option forward          REJECT
        option masq             1
        option mtu_fix          1

config forwarding
        option src              lan
        option dest             wan

增加以上红色部分,使lan口数据可以转发到WAN口,不过这项在openwrt应该是默认配置好的,所以正常情况防火墙规则是不需要另外配置的;

以上是关于Openwrt开发之wifi ap设置的主要内容,如果未能解决你的问题,请参考以下文章

请教一些问题,关于openwrt连接AP的?

使用openwrt(LEDE)桥接两个无线接口

1 Openwrt无线中继设置并访问外网

openwrt上wifi探针的实现

Esxi虚拟机安装Ros+Openwrt软路由双系统简单分享(踩到的坑,很大的坑)

WIFI模块开发教程之W600网络篇1:AP模式下TCP Client通信