LEDE(openwrt) 树莓派3 raspberry pi3 配置为路由器router(含IPv6)
2017-09-22 22:05
2051 查看
烧写镜像
项目组购进了一批树莓派3,想用openwrt使之成为一个路由器,但是
openwrt目前不支持树莓派3,只有他的分支
LEDE可以支持
raspberry pi3
官方源
https://downloads.lede-project.org/,注意要选择
releases版本,笔者一度使用了
snapshots版本,发现默认
opkg(一个
apt-get一样的存在) 源不存在,更改后也没有成功,只能重新下载镜像后烧写。
官方镜像下载地址
https://downloads.lede-project.org/releases/17.01.2/targets/brcm2708/bcm2710/lede-17.01.2-brcm2708-bcm2710-rpi-3-ext4-sdcard.img.gz
(树莓派系列的代号是1代2708,2代2709以及3代2710)
官方镜像大概8M,作为备份,中科大的源也可以使用
http://mirrors.ustc.edu.cn/lede/releases/17.01.2/targets/brcm2708/bcm2710/lede-17.01.2-brcm2708-bcm2710-rpi-3-ext4-sdcard.img.gz,在国内速度官方源要快一些。
解压缩后大概300M,烧写方式不在此赘述。(本人是在
windows下用
SD Card Formatter和
Win32DiskImager)
安装luci和usb有线网卡
树莓派只有一个网卡(千兆),所以需要再接一个外接网卡,但是由于usb口传输速率限制,无法做到双臂千兆,这里我购买了CE-LINK的百兆网卡,其内置芯片是RTL8152,外接网卡不能直接使用,需要驱动。
这里,下载安装驱动使用
opkg,但需要首先配置网络。
首次进入
LEDE根据提示更改密码,
passwd
连接网线,配置网络,修改
/etc/config/network,如果是静态地址,添加
config interface 'wan' option ifname 'eth0' option proto 'static' option ipaddr 'xxx.xxx.xxx.xxx' option netmask '255.255.255.0' option gateway 'xxx.xxx.xxx.xxx' option dns 'xxx.xxx.xxx.xxx'
另外,将
lan的
ifname暂时改成
wlan0防止冲突。
完成修改后,
reboot,再
ping www.baidu.com测试。
网络可达后,首先安装
luci
opkg update opkg install luci
注意:每次重启后都要运行
opkg update,否则
opkg不正常工作
下面安装网卡驱动
opkg install kmod-libphy opkg install kmod-mii opkg install kmod-usb-net opkg install kmod-usb-net-rtl8152
最后一条命令根据自己的有线网卡芯片型号修改。
安装后出现
Configuring kmod-usb-net. failed to find a module named usbnet Collected errors: * pkg_run_script: package "kmod-usb-net" postinst script returned status 255.
是正常现象,不影响使用(ipk包和之前分支的问题),在之后每次使用
opkg 的时候也都会出现。
这时,我们可以ip a
看到eth1,将
network文件中的
lan的
ifname改为
eth1,路由器基本成形了。
用网线连接外接网卡,默认
192.168.1.1是
luci的地址,
启动
luci
/etc/init.d/uhttpd start /etc/init.d/uhttpd enable
可以用浏览器访问进行配置,另外其默认开启
ssh访问。
luci
luci界面很是好用,值得大家探索,另外也可以安装luci-i18n-base-zh-cn包来获取中文界面,安装后在 系统-语言和界面 处修改。
换源
虽然官方源可用,但是还是提供换源的方式,修改/etc/opkg/distfeeds.conf
将网址中的
http://downloads.lede-project.org/换成其他源,这里推荐中科大源。
ipv6
由于校园网有原生的IPv6,所以我配置了
nat66
opkg install ip6tables kmod-ipt-nat6
wan的配置,增加一个
interface,因为无法同时
static v4和
dhcp v6
config interface 'wan6' option proto 'dhcpv6' option reqaddress 'try' option reqprefix 'auto' option _orig_ifname 'eth0' option _orig_bridge 'false' option ifname 'eth0'
注意,在
luci下经过奇妙配置可能出现
option _orig_bridge 'true'改不回去,所以尽量在命令行下配置。(再次安装的时候,又是死活拿不到地址,好像是玄学问题,准备认真学习
DHCPv6后解决这个问题)
这时,树莓派应该已经能够拿到地址,并且可以访问
IPv6
可以使用
http://simpledns.com/private-ipv6.aspx生成随机私有地址,在
lan下增加
option ip6assign '64' option ip6ifaceid 'xxxx:xxxx:xxxx:xxxx'
并更改
config globals 'globals' option ula_prefix 'xxxx:xxxx:xxxx:xxxx::/64'
此时,
lan口有
IPv6私有地址。
之后的步骤参见
https://lixingcong.github.io/2017/04/24/ipv6-nat-lede/
即可实现
nat66
相关文章推荐
- Alphabot树莓派教程:刷LEDE(OpenWRT)系统变身路由器
- PIX+Router实现远程接入的路由器配置
- 树梅派应用19:树莓派安装OpenWRT做路由器图文详解
- 树莓派3配置无线网卡连接路由器
- raspberry pi 2B刷路由器固件openwrt
- 树梅派应用35:安装OpenWrt将树莓派变身为全能路由器
- 为OpenWrt配置IPV6,享受下一代互联网
- 树莓派: raspberry pi 和电脑直连 (无显示器,无路由器,无USB wifi)
- 树莓派官方推荐的VNC Viewer配置详解Raspberry Pi3 B+
- [转]Raspberry Pi树莓派无线网卡配置[多重方法备选]
- 【代码分享】分享基于openwrt的PandoraBox路由器的dnsmasq.conf配置代码
- 树莓派扩展 IPv6无线路由配置(一)
- Raspberry Pi(树莓派)上安装Raspbian(无路由器,无显示器)
- 手动配置 OpenWrt 路由器的 DNS 服务
- (一)无显示器无键盘无路由器,最简方式配置树莓派
- Raspberry Pi树莓派无线网卡配置[多重方法备选]
- 树莓派3(Raspberry pi 3)刷OpenWrt