- 系统硬件:树莓派一个,8G sd卡一个,usb无线网卡一个,usb键盘、显示器等外设。
- 操作系统:raspbian wheezy
- 配置eth0为dhcp自动获取地址,wlan0为固定ip,安装isc dhcp和hostap实现从eth0把ipv4分享到无线网卡上。
- 安装yah3c,实现从eth0进行宿舍的上网认证。ipv4的分享至此结束。
- 安装bridge-utils 和 ebtables ,用来建立ipv6网桥。
- 建立ipv6网桥。
ifconfig eth0 down
ifconfig eth2 down #关闭两块网卡
brctl addbr br0
ifconfig br0 up #启动网桥
brctl addif br0 eth0
brctl addif br0 eth2 #桥接两块网卡
ebtables -t broute -A BROUTING -p ! ipv6 -j DROP #只允许ipv6包通过网桥
ifconfig eth0 up
ifconfig eth2 up #启动网卡
具体参见:http://bigeagle.me/2011/11/linux_as_ipv6_gateway/
- 把以上代码写入/etc/rc.local中,以便开机自动启动。