JETFIRE & Karmatek - Living On The Edge (Official Audio)

R3HAB & Skytech - Everything

Jay Hardway - Electric Elephants (Official Music Video)

7UBO - Furia

Akiko Wada - YONA YONA DANCE

Nightcore - My Forever

Alex Aster - Divine (Lyrics)

Light Dance - sakanaction

サカナクション / 多分、風。 -Music Video-

Ummet Ozcan - Xanadu (Mongolian Techno)

M83 - Midnight City (Lyrics)

La La La (VK Remix)

Legends Never Die: Remix (ft. Alan Walker) | Worlds 2017 - League of Legends

海鸟飞鱼 - 思念绕指尖 (DJ名龙版)

往期优秀作品推荐

2022年11-12月

内网dns服务器可以参考的一些配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Never forward plain names (without a dot or domain part)
# 不包含点(.)的域名不要发给上游DNS服务器(不会流出当前节点)
domain-needed

# Never forward addresses in the non-routed address spaces.
# 无法路由的地址不要发给上游DNS服务器(不会流出当前节点)
bogus-priv

# If you don't want dnsmasq to read /etc/resolv.conf or any other
# file, getting its servers from this file instead (see below), then
# uncomment this.
# 不读取/etc/resolv.conf, 因为里面只有namserver 127.0.0.1
no-resolv

# Add other name servers here, with domain specs if they are for
# non-public domains.
# 对于解析不了的域名, 转发某个上游DNS服务器
server=192.168.50.1

# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only.
# 对于.in39结尾的域名都视为内网, 不转发给上游DNS服务器.
local=/in39/

# Add domains which you want to force to an IP address here.
# The example below send any host in double-click.net to a local
# web-server.
# 解析, 泛解析域名到IP, 如下*.helloworld.in39和helloworld.in39都会解析到这个IP
# 域名本身也可以加通配符来做字符串匹配解析.
address=/helloworld.in39/192.168.50.1

# If you don't want dnsmasq to read /etc/hosts, uncomment the
# following line.
# 不要读取/etc/hosts
no-hosts

# or if you want it to read another file, as well as /etc/hosts, use
# this.
# 但是读取以下指定的文件作为hosts内容 格式和hosts保持一致. 多个IP可以解析到同一个域名, dnsmasq可以正确解析.
addn-hosts=...

# Include another lot of configuration options.
# conf-file=/etc/dnsmasq.more.conf
# 可以把配置文件分离到其他文件或文件夹里, 可以有多个
conf-dir=...

参考

dnsmasq - ArchWiki

Wildcard subdomains with dnsmasq

Stop DNSMasq From Forwarding Local Hostnames

Assign multiple IPs to 1 Entry in hosts file

Is there a way to use a specific DNS for a specific domain?

有个简短的视频可以参考 Configuring DNS With Dnsmasq and Ubuntu Server

问题现象

需求是将服务的UDP流量从机器A切换到机器B. 路由器操作前机器A和机器B相关服务已准备就绪. 切换期间上游会一直有流量过来.

路由器设置端口转发, UDP协议, 外部端口保持不变的情况下改变内部IP, 保存后不生效, UDP包仍然会发送到原来的内网IP.

在机器A上运行tcpdump:

1
2
06:13:05.130930 IP (tos 0x28, ttl 61, id 60828, offset 0, flags [none], proto UDP (17), length 176)
##.##.##.##.51820 > ##.##.##.##.51820: UDP, length 148

注意此时机器A上已没有服务监听在目标端口, 已通过iptables DROP来源包, 否则会有ICMP不可达报文

1
2
3
4
05:48:51.052956 IP (tos 0xc8, ttl 64, id 24675, offset 0, flags [none], proto ICMP (1), length 204)
##.##.##.## > ##.##.##.##: ICMP ##.##.##.## udp port 51820 unreachable, length 184
IP (tos 0x28, ttl 61, id 15781, offset 0, flags [none], proto UDP (17), length 176)
##.##.##.##.51820 > ##.##.##.##.51820: UDP, length 148

在机器B(新的目标机)运行tcpdump接收不到包.

问题排查

机器A和B本地排查无果, 登录路由器进行排查.

运行conntrack -L:

1
2
udp      17 47 src=[远端机器的IP] dst=[路由器公网侧IP] sport=51820 dport=53820 src=[机器A的IP] dst=[远端机器的IP] sport=51820 dport=51820 [ASSURED] mark=0 use=1
conntrack v1.4.5 (conntrack-tools): 686 flow entries have been shown.

运行iptables -t nat -vnL

1
0    0 DNAT       udp  --  *      *       0.0.0.0/0            0.0.0.0/0            udp dpt:53820 to:192.168.50.3:53820

可以看到端口转发配置是生效的, 但是因为有conntrack规则的存在所以后续来的包并没有被当成”新的链接”走iptables, 而是继续按照conntrack中的规则进行转发.

这里比较怀疑这个特定版本的conntrack可能经过魔改, 查到的标准是180秒内如果没有回包, conntrack规则就应该被移除. 但实际上在路由器上可以看到:

1
2
3
4
5
6
udp      17 1 src=##.##.##.## dst=##.##.##.## sport=51820 dport=53820 src=##.##.##.## dst=##.##.##.## sport=51820 dport=51820 [ASSURED] mark=0 use=1
conntrack v1.4.5 (conntrack-tools): 710 flow entries have been shown.
udp 17 0 src=##.##.##.## dst=##.##.##.## sport=51820 dport=53820 src=##.##.##.## dst=##.##.##.## sport=51820 dport=51820 [ASSURED] mark=0 use=1
conntrack v1.4.5 (conntrack-tools): 710 flow entries have been shown.
udp 17 179 src=##.##.##.## dst=##.##.##.## sport=51820 dport=53820 src=##.##.##.## dst=##.##.##.## sport=51820 dport=51820 [ASSURED] mark=0 use=1
conntrack v1.4.5 (conntrack-tools): 707 flow entries have been shown.

很明显, 规则定时归0时没有被删除而是重置了倒计时.

解决方案

在路由器上, 使用命令删除这条规则: conntrack -D -p udp --dport 53820

删除后马上在机器B的tcpdump上就可以看到来自远端机器的UDP流量了.

参考

portmap: delete UDP conntrack entries on teardown · Issue #123 · containernetworking/plugins

在CNI github issue里找到了一个类似的问题, 带udp端口转发的pod移除的时候需要手动调conntrack删除掉NAT规则, 否则流量将无法分配到新的pod上. 但这种场景里路由器(上层NAT设备)一般是不在控制范围内的, 可能除了在远端发起换端口之外没有任何办法了…

netfilter: Kill unreplied conntracks by ICMP errors

这里有一个patch提议说可以用ICMP错误回包来剔除掉netfilter conntrack里无效的规则, 但应该没有被merge到linux kernel里.

Linux Packet Filtering and iptables - 7.5. UDP connections

Iptables Tutorial 1.2.1 - 7.5. UDP connections

The conntrack-tools user manual

Conntrack tales - one thousand and one flows

Connection Tracking (conntrack): Design and Implementation Inside Linux Kernel

勇 敢 勇 敢 我 的 拓 海

【公式】 ベノム/かいりきベア feat.flower

【公式】 ダーリンダンス/かいりきベア feat.初音ミク

学 E U R O B E A T

軟硬為Eason打做麥當勞新廣告歌 麦当劳无限好完整版

【抖音热歌】越南神曲See Tình 叮叮当当 中文字幕 无损音质 | See Tình (Cucak Remix DJ抖音版) - Hoàng Thùy Linh『叮叮当当 Tình tình tình tang tang tính。』【動態歌詞】♪ 抖音 waywayway 叮叮当当

Funkytown 鸡块旋转一分钟BGM

Illusionary Daytime (抖音 Tiktok Remix FKhouse 2022) || Hot Tiktok Douyin 抖音热播 坤坤摇BGM

ブルーアーカイブ Blue Archive OST 7. Unwelcome School

兔裹煎蛋捲 - 覓紅【歌詞字幕 / 完整高清音質】♫「不愁無處覓紅去 尋香自相見…」Tuguo Jiandan Juan - Seek Red 某个水浒传混剪用的BGM

Sunseting Billows 惊涛落日 昊京变身BGM

Tower of Flower

Lycoris Recoil ED - Tower of Flower Remix v2

Sad Eye, Chris Kilroy - California Crush (feat. Swedish Red Elephant)

BENEE - Supalonely ft. Gus Dapperton

【maimai】花と、雪と、ドラムンベース。/kanone feat. せんざい 据说是maimai圈的梗曲

Mike Williams X Curbi - Take Me There (Official Music Video)

Dimitri Vegas, Martin Garrix, Like Mike - Tremor (Official Music Video)

Hardwell, KAAZE & Jonathan Mendelsohn - We Are Legends (Full Video)

Darren Styles - The Dragon (Official Video) | 致 命 节 奏

Imagine Dragons - Thunder (Lyrics)

The Tech Thieves - Fake

Brooks & GRX - Boomerang (Official Video)

Don’t Care - S3RL & IC3MANIA ft Kayliana

Aiobahn feat. KOTOKO - INTERNET OVERDOSE (Official Music Video) [Theme for NEEDY GIRL OVERDOSE]

⚡团 长 在 沈 阳 当 姬 吧⚡

Calvin Harris - Outside (Official Video) ft. Ellie Goulding

KSHMR - Wildcard (ft. Sidnie Tipton) 结尾有特殊变化的Wildcard KSHMR - The Lion Across The Field EP

「补档」理塘金曲:I Got Smoke(1376届格莱美说唱钻石单曲)1080P 新的大山

蔡健雅-紅色高跟鞋『你像窝在被子里的舒服』【動態歌詞Lyrics】 红色高跟鞋

【香蜜沉沉燼如霜】左手指月–薩頂頂《自製歌詞MV》 左手指月

春天的芭蕾 原唱常思思

Snow Halation - µ’s [FULL ENG/ROM LYRICS + COLOR CODED] | Love Live!

往期优秀作品推荐

2022年9-10月

WebUI上的Local DNS只支持添加完整域名的解析, 输入泛解析会报错.

创建dnsmasq配置文件: sudo vim /etc/dnsmasq.d/02-wildcard-dns.conf

1
address=/域名/IP

此处域名不需要带*.前缀, 直接写完整部分即可. 例如 example.com, 添加后 *.example.com 都会被解析到这个IP地址.

重新加载配置 sudo systemctl reload pihole-FTL.service 也可以使用restart

参考

Wildcard DNS in Pihole

Is it possible to add a wildcard CNAME into dnsmasq?

我想静静 - 秋裤大叔 (DJ阿遠Remix)

雪十郎 - 伤过的心(DJ小鱼儿 Remix)『世上的人总有千千万万没有了谁都能继续表演』【可视化音乐歌词版】超高无损音质

雪十郎、龙左 - 爷们要战斗 (抖音热播DJ版) Nam Tử Hán Phải Chiến Đấu (Remix)『我爸说了,是个爷们儿,就应该去战斗,爷们要战斗』【抖音火流行歌曲推荐TikTok】

Five Nights at Freddy’s 2 Song - The Living Tombstone (FNAF2)

Five Nights at Freddy’s 4 Song - I Got No Time (FNAF4) - The Living Tombstone

【陰キャの逆襲】イナくなっちゃえ大作戦 / みつあくま feast. 初音ミク(DOMESTIC Revenger)

Orange Range - Sushi Tabetai feat. Soy Sauce

Full Sail - Demented Sound Mafia

往期优秀作品推荐

2022年8月

本文主要关注基于ip命令的配置, 尽量避免使用ifconfig, route, brctl等传统命令, 尽量避开使用systemd-network等网络管理器.

本文基于 利用OSPF协议实现WireGuard高可用 并假设已存在一个由WireGuard安全点对点连接组成的网络, 且网络中运行一种IGP协议(例如OSPF).

OSPF Network Diagram

网络拓扑如上图. 其中点对点链路均使用/30网段, 各路由器均运行OSPF协议. 现在想利用Router 10.65.1.1, 10.65.1.2 两台机器实现Router 10.65.2.210.65.2.1 流量最大化通信.

由于WireGuard本身运行在L3/IP层, 且官方版本不支持设置mac地址(有魔改版据说做到了), 我们无法利用Linux本身提供的Bonding功能来做原生负载均衡. 因此可以在 10.65.2.210.65.2.1 之间分别搭建两条经过不同路由的GRE隧道, 然后在两侧分别将两个GRE端口绑定起来.

GRE Tunnel Diagram

需要注意的是, GRE隧道分为GRE和GRETAP, 其中GRE也是运行在L3的, GRETAP则是运行在L2的. 尽管GRE没有加密功能, 但由于外层隧道本身是加密的, 所以不会有安全问题, 也避免了多次加密带来的性能损耗.

首先加载必要的kernel module (不过这一步似乎可以省略, 因为新建gre设备的时候会自动加载)

1
2
modprobe ip_gre
modprobe bonding

创建GRE隧道

在Router 10.65.2.2上:

1
2
3
4
5
6
7
ip link add gre1 type gretap local 10.65.0.2 remote 10.65.0.6 ttl 255
ip addr add 10.66.0.1/24 dev gre1
ip link set dev gre1 up

ip link add gre2 type gretap local 10.65.0.14 remote 10.65.0.10 ttl 255
ip addr add 10.66.1.1/24 dev gre2
ip link set dev gre2 up

在Router 10.65.2.1上:

1
2
3
4
5
6
7
ip link add gre1 type gretap local 10.65.0.6 remote 10.65.0.2
ip addr add 10.66.0.2/24 dev gre1
ip link set dev gre1 up

ip link add gre2 type gretap local 10.65.0.10 remote 10.65.0.14
ip addr add 10.66.1.2/24 dev gre2
ip link set dev gre2 up

此时两侧应该可以通过gre隧道ping通:

1
2
3
PING 10.66.0.2 (10.66.0.2) 56(84) bytes of data.
64 bytes from 10.66.0.2: icmp_seq=1 ttl=64 time=...
...

创建Bonding

注意: 向bonding添加slave时, 对应的设备状态不能为up.

在Router 10.65.2.2上:

1
2
3
4
5
6
7
8
9
10
11
12
13
ip link add bond0 type bond
ip link set dev bond0 type bond mode balance-rr
ip addr add 10.67.0.1/24 dev bond0

ip link set dev gre1 down
ip link set dev gre1 master bond0
ip link set dev gre1 up

ip link set dev gre2 down
ip link set dev gre2 master bond0
ip link set dev gre2 up

ip link set dev bond0 up

这里, 由于需求是尽量使用带宽, 这里采用了balance-rr模式, 即平均分配入流量到两个接口上. 此外还有 active-backup, balance-xor, broadcase, 802.3ad, balance-tlb, balance-alb 等模式.

在Router 10.65.2.1上:

1
2
3
4
5
6
7
8
9
10
11
12
13
ip link add bond0 type bond
ip link set dev bond0 type bond mode balance-rr
ip addr add 10.67.0.2/24 dev bond0

ip link set dev gre1c down
ip link set dev gre1c master bond0
ip link set dev gre1c up

ip link set dev gre2c down
ip link set dev gre2c master bond0
ip link set dev gre2c up

ip link set dev bond0 up

此时两侧应该可以通过bond0的地址ping通:

1
2
3
PING 10.67.0.1 (10.67.0.1) 56(84) bytes of data.
64 bytes from 10.67.0.1: icmp_seq=1 ttl=64 time=...
...

不知道为什么, 在两侧bond0都启动完成后, 如果只从一侧开始ping刚开始并不能ping通, 如果此时从另一侧也开始ping, 那么两侧从此都可以互相ping通. 推测可能是没有给bond0设置miimon等参数导致的. (MIIMON是Media Independent Interface Monitoring的缩写)

bonding的状态可以通过 /proc/net/bonding/bond0 获取:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0

Slave Interface: gre1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: ...
Slave queue ID: 0

Slave Interface: gre2
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: ...
Slave queue ID: 0

至此已基本搭建完毕. 在两侧通过bond0的地址使用iperf3进行测速, 实测可以达到几乎双倍的速度.

另外, 由于底层网络基于WG+OSPF, 当网络中有节点掉线的时, bond接口会有短暂的丢包(实际观测看要>50%, 几乎65%) 经过一段时间OSPF完成收敛后(默认配置下大约45秒), bond接口就会恢复正常. 推测如果bond接口本身配置了miimon可能在bond层会先剔除掉超时的slave.

最后我们来计算一下开销:

GRE with WireGuard Packet

只考虑IPv4的情况下, 从外到内分别是:

  • 外层IPv4, 20 bytes
  • UDP, 8 bytes
  • WireGuard, 32 bytes
  • 内层IPv4, 20 bytes
  • GRE, 4 bytes
  • 以太网帧头部, 14 bytes (因为用的是L2 GRETAP)

最终在基础MTU=1500的前提下, 最内层MTU还剩下1402. 如果外层内层均更换为IPv6, 由于IPv6 header为40 bytes, 那么最后留给最内层的MTU还剩下1362, 距离IPv6要求的最低1280还有一点空间.

最开始给gre隧道挂到bridge下面了, 结果两边bridge一开直接回环网络风暴… = =||

参考资料

GRE bridging, IPsec and NFQUEUE

SETUP GRE TUNNEL ON UBUNTU 20 LINUX SERVER

Syntax for changing the bond mode of an interface

ip-link(8) — Linux manual page

networking:bonding [Wiki]

Bonding - Debian Wiki

7.7. Using Channel Bonding

10.5 Configuring Network Interface Bonding

Switch flooding when bonding interfaces in Linux

A Beginner’s Guide to Generic Routing Encapsulation

How to create a GRE tunnel on Linux

Marnik - Up & Down (Official Video)

Schadenfreude - S3RL

OUTRAGE & Jetty Rachers & Hi3ND - Desire

YOASOBI「三原色」Official Music Video

Doki Doki ドキドキ - S3RL ft Kawaiiconic

Wanna Fight Huh - S3RL

PinocchioP - Magical Girl and Chocolate feat. Hatsune Miku | 【初音ミク】魔法少女とチョコレゐト【ピノキオピー】

PinocchioP - SLoWMoTIoN feat. Hatsune Miku

【脈アリ?】最近カレ死が冷たいの / みつあくま feat. 初音ミク【プロセカNEXT】 (Necro-Fantasista)

【ママに内緒で】ショウコ隠滅、少女純潔 / みつあくま fealty. 初音ミク【プロセカNEXT】 (Virgin birth) | 【初音ミク】【对妈妈保密】消灭证据,少女纯洁【みつあくま】 (Virgin birth)

“終わカレ”はブロックで / みつあくま fear. 初音ミク【プロセカNEXT】(My ex Blocker)

Anemone / mitsu_devil

Ephemeral Melody

往期优秀作品推荐

2022年6-7月

Jannik - Grace 惊鸿 / 网易云音乐

PinocchioP - God-ish feat. Hatsune Miku / 【初音ミク】神っぽいな (像神一样呐)【ピノキオピー】

【五学】像阁下一样呐

The Weeknd - Out of Time (Official Video) 103.5 DAWN FM

R3HAB & KSHMR - Strong (Official Music Video)

Marnik, LUNAX - Bye Bye Bye (Lyrics Video)

Doja Cat - Vegas (From the Original Motion Picture Soundtrack ELVIS) (Official Video)

伊格赛听 & 叶里 - 谪仙(DJ名龙)「称谪仙瑶宫难留,去凡间红楼斗酒」【動態歌詞/pīn yīn gē cí】

麦小兜 - 下山【動態歌詞/Lyrics Video】

往期优秀作品推荐

2022年5月

现象: WmiPrvSE.exe(SYSTEM)高CPU占用.

排查原因: 事件查看器 应用程序和服务日志/Microsoft/Windows/WMI-Activity/Trace 右键启用日志. 可以看到里面提示了发起WMI调用的ClientProcessId, 定位到进程 AUEPMaster.exe

解决方案: Ryzen Master 设置/用户体验计划/AMD用户体验计划 选择退订即可.

参考

WMI Provider Host at high usage due to AUEPMaster.exe causing errors.

Web-Based Enterprise Management Wbem

WMI-Activity Event 5858 logged frequently with ResultCode 0x80041032