海运的博客

n1盒子连接手机4G无线热点做k2p宽带pppoe备份线路并切换

发布时间:February 24, 2021 // 分类:N1,K2P // No Comments

k2p主路由地址:192.168.1.1
n1盒子地址:192.168.1.2
k2p添加低优先级默认路由走n1,此路由只有pppoe断开后才有效:

ip rou add default via 192.168.1.2 dev br-lan metric 1000

n1盒子用netplan配置无线网络默认路由和无线热点的路由优先级,默认情况下走k2p主路由,当路由器pppoe不能连接时打开手机无线热点则自动走手机4g网络连接。

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            addresses:
            - 192.168.1.2/24
            dhcp4: false
            dhcp6: true
            accept-ra: true
            #gateway4: 192.168.1.1
            routes:
                - to: 0.0.0.0/0
                  via: 192.168.1.1
                  metric: 1000
            nameservers:
                addresses:
                - 192.168.1.1
                search: []

    wifis:
      wlan0:
        #防止开机时wlan0未连接导致systemd-networkd-wait-online阻塞系统启动
        optional: true
        dhcp4: yes
        dhcp6: no
        dhcp4-overrides:
            route-metric: 600
        access-points:
            "Phone-ssid":
                password: "www.haiyun.me"

n1盒子开启snat及网络转发:

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sysctl -w net.ipv4.ip_forward=1

ImageBuilder制作k2p潘多拉/PandoraBox固件

发布时间:November 2, 2018 // 分类:K2P // 8 Comments

基于ubuntu 18.04,安装依赖:

apt install build-essential libncurses5-dev zlib1g-dev gawk git  libssl-dev wget unzip python ocaml-nox help2man texinfo yui-compressor

下载最新版本18.10的ImageBuilder:

https://downloads.pangubox.com/pandorabox/18.10/targets/ralink/mt7621/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64.tar.xz
tar Jxf PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64.tar.xz
cd PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64

查看可编译的固件型号及其包含的软件包:

make info

制作固件:

#info显示的所有机型固件
make image
#仅制作k2p固件
make image PROFILE="k2p"
#安装额外的软件包,自编译软件先把软件放到packages/目录下
make image PROFILE="k2p" PACKAGES="wget"
#添加files目录内文件到固件内,如files/etc/config/network网络配置文件
make image PROFILE="k2p" FILES="files"
#查看更多选项
make help

默认的软件包在以下两个文件内:

include/target.mk
.profiles.mk 

开始使用默认配置制作k2p固件:

make image PROFILE="k2p"

遇到以下错误:

 regexp could be something like 'pkgname*' '*file*' or similar
 e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'
Makefile:140: recipe for target 'package_install' failed
make[2]: *** [package_install] Error 1
make[2]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:110: recipe for target '_call_image' failed
make[1]: *** [_call_image] Error 2
make[1]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:196: recipe for target 'image' failed
make: *** [image] Error 2

因为在Makerfile 144行要预先安装kernel文件,而package没kernel软件包,下载kernel:

wget https://downloads.pangubox.com/pandorabox/18.10/targets/ralink/mt7621/packages/kernel_3.14.79-1_mipsel_1004kc_dsp.ipk -P packages/

再次执行又出现错误:

Collected errors:
 * opkg_install_cmd: Cannot install package dosfsck.
 * opkg_install_cmd: Cannot install package fkmod-leds-gpio.
 * opkg_install_cmd: Cannot install package kmod-ipt-nathelper.
 * opkg_install_cmd: Cannot install package mkdosfs.
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for ralink-utils:
 *      kmod-ipt-nathelper-extra * 
Makefile:140: recipe for target 'package_install' failed
make[2]: *** [package_install] Error 255
make[2]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:110: recipe for target '_call_image' failed
make[1]: *** [_call_image] Error 2
make[1]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:196: recipe for target 'image' failed
make: *** [image] Error 2

因为新版的openwrt将kmod-ipt-nathelper-extra 更改为kmod-nf-nathelper-extra,而潘多拉的源package没修改依赖,使用以下脚本在制作时更新源后修改软件依赖项kmod-ipt-nathelper-extra为kmod-nf-nathelper-extra:

#!/bin/bash
for file in `ls dl/18.10*`;do 
        echo $file;
        mv $file $file.gz
        gunzip $file.gz
        sed -i 's/kmod-ipt-nathelper-extra/kmod-nf-nathelper-extra/g' $file
        gzip -9 $file
        mv $file.gz $file
done
sed -i 's/kmod-ipt-nathelper/kmod-nf-nathelper/g' include/target.mk 

将以上保存为fix.sh到image build目录加可执行权限,并修改Makefile文件在122行$(MAKE) package_install前插入:

$(TOPDIR)/fix.sh

再次执行又遇到以下错误:

Collected errors:
 * opkg_install_cmd: Cannot install package dosfsck.
 * opkg_install_cmd: Cannot install package fkmod-leds-gpio.
 * opkg_install_cmd: Cannot install package mkdosfs.

因为上面这3个软件有的改名,有的名字写错,修复下:

sed -i 's/fkmod-leds-gpio/kmod-leds-gpio/g' .profiles.mk
sed -i 's/mkdosfs dosfsck/dosfstools/g' .profiles.mk
````
再次执行终于制作完成k2p固件,将制作的固件scp到路由/tmp/目录开始刷机:

scp bin/targets/ralink/mt7621/PandoraBox-ralink-mt7621-k2p-2018-10-26-git-85c67caa2-squashfs-sysupgrade.bin 192.168.168.1:/tmp/

k2p路由内使用[sysupgrade命令刷机][1]:

sysupgrade -n -v /tmp/PandoraBox-ralink-mt7621-k2p-2018-10-26-git-85c67caa2-squashfs-sysupgrade.bin

分类
最新文章
最近回复
  • crowjin: 你确定这能过滤??不是所有请求都返回空地址::?
  • : linux系统上单个网卡多条宽带拨号获取公网IP,外网可以访问这些IP,有偿! Q:25299...
  • 硅谷少年: 非常有用,感谢分享
  • spartan2: https://dashboard.hcaptcha.com/welcome_accessib...
  • 海运: 应该能,在购买页面先手工跳过cf机器验证,后续一定时间内不更换ip应该不会再次验证。
  • spartan: 大佬斯巴达开启了CF的机器识别验证,请问插件能自动跳过吗? 另外这个脚本有没有简单使用说明,新...
  • vincent: 膜拜大佬
  • 海运: proxy-header或proxy_protocol
  • liangjw: 如果是 内部调用 或者 中间存在 代理 而上一个代理又在内网 ,那怎么处理来自代理私有IP?
  • chainofhonor: 感谢,用dnsmasq设置自动判断BIOS和UEFI成功了