openwrt 使能wifi 修改ip wan lan 口

openwrt运行环境下:

root@OpenWrt:~# vim /etc/config/network 

        option ipaddr '127.0.0.1'                                              

        option netmask '255.0.0.0'                                              

                                                                               

config globals 'globals'                                                        

        option ula_prefix 'fd8b:eba0:e97a::/48'                                

                                                                               

config interface 'lan'                                                          

        option ifname 'eth1'                                                    

        option force_link '1'                                                  

        option type 'bridge'                                                    

        option proto 'static'                                                  

        option netmask '255.255.255.0'                                          

        option ip6assign '60'                                                  

        option ipaddr '192.168.2.1'       修改lan口IP                                      

                                                                               

config interface 'wan'                                                          

        option ifname 'eth0'                                                    

        option proto 'dhcp'                                                    

                                                                               

config interface 'wan6'                                                        

        option ifname '@wan'                                                    

        option proto 'dhcpv6'                                                  

                                                                               

config switch                                                                  

        option name 'switch0'                                                  

        option reset '1'                                                        

        option enable_vlan '1'                                                  

                                                                               

config switch_vlan                                                              

        option device 'switch0'                                                

        option vlan '1'                                                        

        option ports '0 2 3 4 5'                                                

                                                                               

config switch_vlan                                                              

        option device 'switch0'                                                

        option vlan '2'                                                        

        option ports '1 6'      

其中swich_vlan就是配置lan口和wan口的接口

 option vlan '1'  对应config interface 'lan'

option vlan '2' 对应config interface 'wan' 

使能wifi信号

root@OpenWrt:~# vim /etc/config/wireless 

config wifi-device 'radio0'

        option type 'mac80211'

        option channel '11'

        option hwmode '11g'

        option path 'platform/qca955x_wmac'

        option htmode 'HT20'

        option txpower '30'

        option country 'US'

config wifi-iface

        option device 'radio0'

        option network 'lan'

        option mode 'ap'

        option ssid 'wdr4900'

        option encryption 'psk2'

        option key '12345678'

config wifi-device 'radio1'

        option type 'mac80211'

        option channel '36'

        option hwmode '11a'

        option path 'pci0000:01/0000:01:00.0'

        option htmode 'HT20'

        option disabled '1' //注释这一行使能5gwifi信号

config wifi-iface

        option device 'radio1'

        option network 'lan'

        option mode 'ap'

        option ssid 'OpenWrt'

        option encryption 'none'

openwrt 编译环境下:

zzq@openwrt_barrier_breaker$ vim ./package/base-files/files/lib/functions/uci-defaults.sh 

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'  //修改默认IP

set network.lan.netmask='255.255.255.0'

set network.lan.ip6assign='60'

EOF

}

ucidef_set_interfaces_lan_wan() {

    local lan_ifname=$1 //$1和$2互换后可 wan和lan口对调

    local wan_ifname=$2

    ucidef_set_interface_lan "$lan_ifname"

    ucidef_set_interface_wan "$wan_ifname"

}

下面这个脚本执行时会调用上面的脚本

zzq@openwrt_barrier_breaker$ vim ./target/linux/ar71xx/base-files/etc/uci-defaults/02_network 

该脚本有这样下面一行

. /lib/functions/uci-defaults.sh 

使能wifi信号

zzq@openwrt_barrier_breaker$ vim ./package/kernel/mac80211/files/lib/wifi/mac80211.sh 

$ht_capab

    # REMOVE THIS LINE TO ENABLE WIFI:

    option disabled 1 注释掉这一行后使能wifi信号

猜你喜欢

转载自blog.csdn.net/u011349664/article/details/86594593