玩客云折腾记2--docker和openwrt安装

用的img是Armbian_20.12_Aml-s812_buster_current_5.9.0-rc7.img
用balenaetcher刷写到U盘
U盘插入usb2(靠近网口)
插电启动
运行/boot里面的install.sh
顺利装入emmc,拔掉upan重启进入系统,该img不支持hdmi显示,需要路由器查看ip后putty连接ssh
该img支持docker,但未安装,需要apt install docker.io
已经换源

装宝塔
docker pull portainer/portainer
docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name portainer-test docker.io/portainer/portainer
访问方式:http://IP:9000
初次进入需要设置大于8位的密码
选择local连接,connnect
拉openwrt:(https://hub.docker.com/r/virking/openwrt)密码是snail
docker pull virking/openwrt:18.06

配置:
开启网卡混杂
ip link set eth0 promisc on

ifconfig eth0 promisc
加入永久,不用重启失效
vim /etc/rc.local
ip link set eth0 promisc on
重启网卡生效
/etc/init.d/networking restart
最佳:/etc/init.d/networking stop; /etc/init.d/networking start

重启

检查
ifconfig
docker搭建macvlan网络
docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=eth0 macnet

docker network ls ## 可查看已创建网络

配置 OpenWrt 容器网络

docker run --restart always -d --network macnet --privileged virking/openwrt:18.06 /sbin/init
查看容器:
docker ps -a
找到容器名字name
进入容器
docker exec -it flamboyant_banzai bash
编辑 OpenWrt 的网络配置文件:
ipaddr是openwrt的网址
vim /etc/config/network

config interface ‘lan’
option type ‘bridge’
option ifname ‘eth0’
option proto ‘static’
option ipaddr ‘192.168.1.254’
option netmask ‘255.255.255.0’
option ip6assign ‘60’
option gateway ‘192.168.1.1’
option broadcast ‘192.168.1.255’
option dns ‘192.168.1.1’

重启网络
/etc/init.d/network restart
推出docker
exit
重启网卡生效
/etc/init.d/networking restart

修复宿主主机网络

cp /etc/network/interfaces /etc/network/interfaces.bak # 备份文件
vim /etc/network/interfaces # 使用 vim 编辑文件
auto eth0
iface eth0 inet manual

auto macvlan
iface macvlan inet static
address 192.168.2.200
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1
pre-up ip link add macvlan link eth0 type macvlan mode bridge
post-down ip link del macvlan link eth0 type macvlan mode bridge

重启
重启 OpenWrt/网络,就可以 192.168.2.254 登录 Docker 里的 OpenWrt 软路由了。密码是snail

你可能感兴趣的:(其他)