Homepage
iYoRoy DN42 Network
About
Friends
Language
简体中文
English
Search
1
Docker下中心化部署EasyTier
1,704 Views
2
Adding KernelSU Support to Android 4.9 Kernel
1,090 Views
3
Enabling EROFS Support for an Android ROM with Kernel 4.9
308 Views
4
在TrueNAS上使用Docker安装1Panel
299 Views
5
2025 Yangcheng Cup Preliminary WriteUp
295 Views
Android
Maintenance
NAS
Develop
Network
Projects
DN42
One Man ISP
CTF
Login
Search
Search Tags
Network Technology
BGP
Linux
BIRD
DN42
C&C++
Android
OSPF
MSVC
AOSP
Windows
Docker
caf/clo
TrueNAS
Interior Gateway Protocol
Services
iBGP
Clearnet
DNS
STL
Kagura iYoRoy
A total of
23
articles have been written.
A total of
11
comments have been received.
Index
Column
Android
Maintenance
NAS
Develop
Network
Projects
DN42
One Man ISP
CTF
Pages
iYoRoy DN42 Network
About
Friends
Language
简体中文
English
1
articles related to
were found.
Configuring Multi-Exit Routing for a Dual-NIC VPS Using PBR
Warning: This is a low-value/watered-down post Background I got a Shenzhen-Hong Kong IEPL machine from a friend. It has two network interfaces, eth0 and eth1, but by default, all traffic goes through eth0. eth1 had no routing configured. I planned to use metrics for basic traffic splitting initially, and then use PBR (Policy-Based Routing) to implement rule-based routing configuration. Configuration The machine's network was initially configured by cloud-init: # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: version: 2 ethernets: eth0: addresses: - 10.10.1.31/16 gateway4: 10.10.0.1 match: macaddress: bc:24:11:f8:42:7a nameservers: addresses: - 223.5.5.5 - 119.29.29.29 search: - [Data Redacted] set-name: eth0 eth1: addresses: - 10.20.1.31/16 - [Data Redacted]/64 gateway4: 10.20.0.1 gateway6: fe80::be24:11ff:fe80:66bb match: macaddress: bc:24:11:50:96:0a nameservers: addresses: - 223.5.5.5 - 119.29.29.29 search: - [Data Redacted] set-name: eth1 After backing up the config, I added metrics: # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: version: 2 ethernets: eth0: addresses: - 10.10.1.31/16 gateway4: 10.10.0.1 match: macaddress: bc:24:11:f8:42:7a nameservers: addresses: - 223.5.5.5 - 119.29.29.29 search: - [Data Redacted] set-name: eth0 + routes: + - to: "default" + via: "10.10.0.1" + # Set metric=50 as the backup exit + metric: 50 eth1: addresses: - 10.20.1.31/16 - [Data Redacted]/64 gateway4: 10.20.0.1 gateway6: fe80::be24:11ff:fe80:66bb match: macaddress: bc:24:11:50:96:0a nameservers: addresses: - 223.5.5.5 - 119.29.29.29 search: - [Data Redacted] set-name: eth1 + routes: + - to: "default" + via: "10.20.0.1" + # Set metric=25 as the preferred exit + metric: 25 Wrote the PBR configuration: # /etc/netplan/90-pbr.yaml network: version: 2 ethernets: eth0: routes: - to: default via: 10.10.0.1 table: 10 routing-policy: - from: 10.10.0.0/16 table: 10 - to: 202.46.[Data Redacted]/32 table: 10 eth1: routes: - to: default via: 10.20.0.1 table: 20 routing-policy: - from: 10.20.0.0/16 table: 20 - to: 38.47.[Data Redacted]/32 table: 20 - to: 23.149.[Data Redacted]/32 table: 20 For IPs that need to be accessed via a specific exit, just add a 'to' type rule and bind it to the corresponding routing table. After finishing, run netplan apply to update the configuration.
14/09/2025
37 Views
0 Comments
0 Stars