当前位置: 首页 > news >正文

记录一次armbian系统搭建路由功能的失败过程

根据

使用 Debian 作为路由器 :: 星野玲的博客
https://blog.bling.moe/post/3/

优化ubuntu dns解析,关掉systemd-resolved - MR__Wang - 博客园
https://www.cnblogs.com/xzlive/p/17139520.html

ChatGPT

背景需求,新入手了一款RK3568系列的小主机,带有2*2.5G+2*1G+WIFI的配置的,想要替换当前的新三路由器

三者相结合

最后半成功的弄出网络上网,重启失效,切换网卡失效

换源,提速

cp  /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse

关掉systemd-resolved

sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved

更新系统包

sudo apt update

使用iwconfig查看网卡名称

root@hinlink-h68k:~# iwconfig
lo        no wireless extensions.eth0      no wireless extensions.eth1      no wireless extensions.enP2p33s0  no wireless extensions.enP1p17s0  no wireless extensions.wlp1s0    no wireless extensions.

得到,eth0,eth1,enP2p33s0,enP1p17s0这么四个网卡

编辑/etc/network/interfaces

sudo  nano /etc/network/interfaces

追加

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
iface eth0 inet6 autoauto enP1p17s0
allow-hotplug enP1p17s0
iface enP1p17s0 inet staticaddress 192.168.3.1/24auto enP2p33s0
allow-hotplug enP2p33s0
iface enP2p33s0 inet staticaddress 192.168.3.1/24auto eth1
allow-hotplug eth1
iface eth1 inet staticaddress 192.168.3.1/24

开启转发 

编辑 /etc/sysctl.conf 文件。

sudo nano /etc/sysctl.conf
在 /etc/sysctl.conf 的末尾添加以下内容。

net.ipv4.ip_forward=1
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.default.forwarding=1
net.ipv6.conf.default.accept_ra=2
net.ipv6.conf.default.use_tempaddr=1

 

应用配置。

sudo sysctl -p

安装dnsmasq
sudo apt-get install dnsmasq

配置DHCP服务器。

sudo nano /etc/dnsmasq.conf

追加如下

port=53

interface=eth1
server=8.8.8.8
enable-ra
log-dhcp
dhcp-range=192.168.3.2,192.168.3.254,1h
dhcp-option=option:router,192.168.3.1
dhcp-option=option:dns-server,192.168.3.1
dhcp-option=option6:dns-server,[fe80::362f:579d:8c86:105b]

interface=enP1p17s0
server=8.8.8.8
enable-ra
log-dhcp
dhcp-range=192.168.3.2,192.168.3.80,1h
dhcp-option=option:router,192.168.3.1
dhcp-option=option:dns-server,192.168.3.1
dhcp-option=option6:dns-server,[fe80::362f:579d:8c86:105b]

interface=enP2p33s0
server=8.8.8.8
enable-ra
log-dhcp
dhcp-range=192.168.3.81,192.168.3.160,1h
dhcp-option=option:router,192.168.3.1
dhcp-option=option:dns-server,192.168.3.1
dhcp-option=option6:dns-server,[fe80::362f:579d:8c86:105b]

配置防火墙规则。

 sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o enP1p17s0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enP1p17s0 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o enP2p33s0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enP2p33s0 -o eth0 -j ACCEPT

 

http://www.lryc.cn/news/62652.html

相关文章:

  • OpenGL与Metal API的Point Sprite
  • 从0搭建Vue3组件库(七):使用 gulp 打包组件库并实现按需加载
  • Python入门教程+项目实战-11.4节: 元组与列表的区别
  • 如何做好采购计划和库存管理?
  • 客户管理系统的作用有哪些?
  • Sqlmap手册—史上最全
  • 《花雕学AI》13:早出对策,积极应对ChatGPT带来的一系列风险和挑战
  • windows开机启动软件、执行脚本,免登录账户
  • Rocky Linux 8 安装实时内核
  • 数据预处理(Data Preprocessing)
  • MySQL数据库——MySQL WHERE:条件查询数据
  • 【JavaEE初阶】多线程(三)volatile wait notify关键字 单例模式
  • git把一个分支上的某次修改同步到另一个分支上,并解决git cherry-pick 冲突
  • S32K3系列单片机开发笔记(SIUL是什么/配置引脚复用的功能·)
  • Linux没网络的情况下快速安装依赖或软件(挂载本地yum仓库源(Repository))
  • 为了安装pip install pyaudio花费不少时间,坑
  • 第十一章 组合模式
  • LeetCode链表OJ题目 代码+思路分享
  • 第06讲:为何各大开源框架专宠 SPI 技术?
  • [Unity] No.1 Single单例模式
  • 【chatGPT知识分享】Flutter web 性能优化基础入门
  • 探索Qt折线图之美:一次详尽的多角度解析
  • minio集群部署,4台服务器+1台nginx
  • 实例分割算法BlendMask
  • 多线程、智能指针以及工厂模式
  • 初探 VS Code + Webview
  • Codeforces Round 864 (Div. 2)(A~D)
  • 第3章-运行时数据区
  • delta.io 参数 spark.databricks.delta.replaceWhere.constraintCheck.enabled
  • Redis知识点