|

本帖最后由 x2009again 于 2023-4-13 20:31 编辑
ps:最近发现在openwrt重启后pppoe拨号出错,今天终于解决了这个问题,修改部分我做了下说明,去掉了钩子,直接挂载,这种openwrt重启后拨号也正常了。
一直用的梅林的固件路由,这次终于下定决心花点时间整整软路由了。因为弱电箱太小了,所以里面放不下路由,放了光猫+网管交换机,然后划分vlan,现在打算用软路由替代梅林路由。
pve版本为7.2,openwrt版本为22.03.3,建议使用22版本,使用21版本dhcp有问题,其他lan口设备无法访问外网(看论坛有人说是防火墙不兼容),22这个版本也有一个问题就是dnsmasq无法正常运行,导致dhcp无法启动,其他设备无法获取ip,后面找到国外论坛一个网友的方案解决了。
下图为原来的网络架构图,网件路由准备改为软路由

openwrt 22.03.3下载地址(支持LXC):https://downloads.openwrt.org/releases/22.03.3/targets/x86/64/openwrt-22.03.3-x86-64-rootfs.tar.gz
下面开始安装openwrt
- 先下载openwrt文件到CT模板
 - 然后安装,我的容器id是108,下面的代理中的108自行替换为你们自己的,还有下面代码中的local一般是local-lvm,参考自己的pve情况修改
- pct create 108 local:vztmpl/openwrt-22.03.3-x86-64-rootfs.tar.gz --rootfs local:8 --ostype unmanaged --hostname OpenWrt --arch amd64 --cores 2 --memory 1024 --swap 0 -net0 bridge=vmbr0,name=eth0
- #mkdir /var/lib/vz/snippets(作废)
- #cp /usr/share/pve-docs/examples/guest-example-hookscript.pl /var/lib/vz/snippets/hookscript.pl(作废)
- #vim /var/lib/vz/snippets/hookscript.pl(作废)
复制代码修改hookscript.pl内容(作废)- 在第36行可以找到以下内容
- # Second phase 'post-start' will be executed after the guest
- # successfully started.
- print "$vmid started successfully.\n";</font>
- <font color="#c0c0c0">
- 修改为
- # Second phase 'post-start' will be executed after the guest
- # successfully started.
- system("lxc-device add -n $vmid /dev/ppp");
- system("lxc-device add -n $vmid /dev/net/tun");
- print "$vmid started successfully.\n";
复制代码下图也作废
 - 修改容器配置文件
- vim /etc/pve/lxc/108.conf
复制代码 添加下面的内容(有修改)
- # 钩子脚本,用于添加 /dev/ppp等设备
- #hookscript: local:snippets/hookscript.pl(作废)
- # openwrt.common.conf是PVE自带的openwrt配置文件示例,内含一些基本设置
- lxc.include: /usr/share/lxc/config/openwrt.common.conf
- # /dev/ppp pppoe拨号等功能需要用到
- lxc.cgroup2.devices.allow: c 108:0 rwm
- lxc.mount.entry: /dev/ppp dev/ppp none bind,create=file
- lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
- # 这里是网卡直通重要的部分(看自己需不需要,不需要的话下面的可以不用添加,其中enp2s0是我的,你们需要的自己看其他教程找这个网口名)。
- lxc.net.1.type: phys
- lxc.net.1.link: enp2s0
- lxc.net.1.flags: up
复制代码
- 然后启动容器,这个时候启动后openwrt的dnsmasq无法正常启动,ssh连接openwrt后修改/etc/init.d/dnsmasq文件

重启dnsmasq
- /etc/init.d/dnsmasq restart
复制代码 检测dnsmasq是否启动有个简单版本,ssh到openwrt后执行netstat -nap,看看有没有一个53端口的dnsmasq在里面,有的话说明dnsmasq已经成功运行了,运行了如果其他设备还是无法上网,用其他设备测试下openwrt的53端口是否可以访问,如果不能访问,在pve上给openwrt的防火墙上开放下端口
openwrt划分vlan
先添加直通网口到网桥设备,不需要网口直通或者只有单网口的可以跳过这步




如果需要访问光猫,添加一个接口到光猫的ip,假如光猫ip为1192.168.1.1

到此基本openwrt已经基本添加完成,下图为openwrt接口全局图

对于有需要ipv6外网访问家里设备的(需要有公网ipv6),需要在openwrt防火墙添加流量规则,下图做个参考

LXC中的openwrt重启一次一般是10s左右,尽量不要关闭openwrt,特别是只有一个wan口的情况下,关闭openwrt可能导致无法连接pve管理了,如果有wifi的话可以参考其他文章把wifi做个接口(类似上图中的lan口),万一出了问题,通过wifi连接可以管理pve。
参考:https://www.right.com.cn/forum/thread-8252802-1-1.html
|
lede单臂路由, openwrt怎么设置dhcp, openwrt怎么安装, openwrt划分vlan, lede单臂路由, openwrt怎么设置dhcp, openwrt怎么安装, openwrt划分vlan, openwrt 安装软件, pve软路由, lede单臂路由, openwrt安装教程
评分
-
查看全部评分
|