最終功能: 無線路由器的主要功能,網口WAN接入,USB無線網卡AP熱點輸出,連上wifi之後跳轉到認證頁面,點擊認證方可上網,有效時間10分鐘,認證成功之後自動訪問指定網址。 文章結尾有編譯好的刷機包下載 硬體準備: 1.Raspberry Pi 2 model B 2.USB無線網卡,我使用的是 ...
最終功能:
無線路由器的主要功能,網口WAN接入,USB無線網卡AP熱點輸出,連上wifi之後跳轉到認證頁面,點擊認證方可上網,有效時間10分鐘,認證成功之後自動訪問指定網址。
文章結尾有編譯好的刷機包下載
硬體準備:
1.Raspberry Pi 2 model B
2.USB無線網卡,我使用的是TL-WN722N 150Mbps 晶元是AR9271
3.操作系統:CentOS 7
4.SD卡8GB
開始之前最好配置好代理,因為編譯過程中所有的依賴會聯網自動下載,會有大部分時間耗在這裡,如果速度慢或者被牆……
配置編譯環境(一定要非root賬戶):
#升級組件 sudo yum update #安裝編譯組件 sudo yum install libtool autoconf automake gcc-multilib bison screen gcc g++ binutils patch bzip2 flex make gettext unzip libc6 git-core git build-essential libncurses5-dev zlib1g-dev gawk quilt asciidoc libz-dev subversion
下載openwrt源碼(新手不建議下載trunk,不是很穩定)
#使用非root用戶登錄,建立openwrt目錄 mkdir openwrt #進入openwrt目錄 cd openwrt #下載openwrt的源碼 git clone git://git.openwrt.org/15.05/openwrt.git
集成nodogsplash 在/openwrt/feeds.conf.default中添加
src-git nodogsplash https://github.com/nodogsplash/nodogsplash.git
設置許可權
sudo chmod -R 777 trunk cd trunk
更新並安裝
./scripts/feeds update -a ./scripts/feeds install -a
根據自己的需要更改系統預設設置,就不細說了,這裡列舉幾個我的設置
#這個目錄下可以放置之前openwrt的備份文件,也就是說相當於openwrt的/etc/目錄 /home/rophie/openwrt/openwrt/package/base-files/files/etc #預設wifi設置 package/kernel/mac80211/files/lib/wifi/mac80211.sh
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 type 'bridge' option proto 'static' option ipaddr '192.168.88.1' option netmask '255.255.255.0' option _orig_bridge 'true' option gateway '192.168.88.1' config globals 'globals' option ula_prefix 'fda9:3639:b1e9::/48' config interface 'wan' option ifname 'eth0' option _orig_ifname 'eth0' option _orig_bridge 'false' option proto 'dhcp'
wireless設置
config wifi-device 'radio0' option type 'mac80211' option channel '11' #這裡根據你的USB無線網卡的U口來定 option path 'platform/bcm2708_usb/usb1/1-1/1-1.5/1-1.5:1.0' option noscan '1' option country 'CN' option hwmode '11n' option htmode 'HT40' option txpower '40' config wifi-iface option device 'radio0' option network 'lan' option mode 'ap' option ssid 'APK-YFKJ' option encryption psk-mixed
option key 88888888
nodogsplash設置
config instance # Set to 1 to enable nodogsplash option enabled 1 # Use plain configuration file as well #option config '/etc/nodogsplash/nodogsplash.conf' option network 'lan' option gatewayname 'OpenWrt Nodogsplash' option maxclients '250' option idletimeout '10' option clientforcetimeout '10' option redirecturl 'http://192.168.88.1:8080' # Your router may have several interfaces, and you # probably want to keep them private from the network/gatewayinterface. # If so, you should block the entire subnets on those interfaces, e.g.: #list authenticated_users 'block to 192.168.0.0/16' list authenticated_users 'block to 10.0.0.0/8' # Typical ports you will probably want to open up. list authenticated_users 'allow tcp port 22' list authenticated_users 'allow tcp port 53' list authenticated_users 'allow udp port 53' list authenticated_users 'allow tcp port 80' list authenticated_users 'allow tcp port 443' list authenticated_users 'allow tcp port 8080' # For preauthenticated users to resolve IP addresses in their # initial request not using the router itself as a DNS server, list preauthenticated_users 'allow tcp port 53' list preauthenticated_users 'allow udp port 53' #list preauthenticated_users 'allow tcp port 8080' # Allow ports for SSH/Telnet/DNS/DHCP/HTTP/HTTPS list users_to_router 'allow tcp port 22' list users_to_router 'allow tcp port 23' list users_to_router 'allow tcp port 53' list users_to_router 'allow udp port 53' list users_to_router 'allow udp port 67' list users_to_router 'allow tcp port 80' list users_to_router 'allow tcp port 8080' list users_to_router 'allow tcp port 443' # See https://github.com/nodogsplash for a full list of available options.
編譯配置
#更新版本號 svn up #進入編譯菜單 make menuconfig Y:選擇Y,該軟體將被編譯,並且加入到你的目標固件里; M:選擇M,該軟體包將會被編譯,但不會被放入固件里。在需要它的時候,可以用OPKG軟體包管理器進行安裝; N:選擇N,該軟體包將不會被編譯,也不會被安裝進固件。 方向鍵是移動游標 回車鍵是確認 空格鍵是選擇,可以代替Y/M/N鍵的使用 /:搜索
Target System 選擇 brcm2708-bcm2709 按Y選中
需要集成的軟體
kmod-usb-core kmod-usb-ohci kmod-usb-uhci kmod-usb2 usbutils kmod-ath kmod-ath9k kmod-ath9k-common kmod-ath9k-htc luci-i18n-base-zh-cn kmod-nls-cp437 kmod-nls-utf8 kmod-fs-vfat kmod-nls-iso8859-1 wireless-tools hostapd
編譯
make V=99
很久之後你已經能夠在/bin/brcm2708下找到openwrt-brcm2708-bcm2709-sdcard-vfat-ext4.img刷機固件了