根据
使用 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 auto
auto enP1p17s0
allow-hotplug enP1p17s0
iface enP1p17s0 inet static
address 192.168.3.1/24
auto enP2p33s0
allow-hotplug enP2p33s0
iface enP2p33s0 inet static
address 192.168.3.1/24
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 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
文章来源地址https://www.toymoban.com/news/detail-424363.html
应用配置。
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文章来源:https://www.toymoban.com/news/detail-424363.html
到了这里,关于记录一次armbian系统搭建路由功能的失败过程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!