Proxmox VE 单 公网IP 配置 NAT 和端口机端口映射

前言

有一台配置较高的服务器装上 PVE 系统放入机房托管,需要创建多个虚拟机使用

配置过程

开启 IPV4, IPV6转发

1
vim /etc/sysctl.conf

文件内写入以下配置

1
2
3
4
5
6
7
8
9
10
11
12
13
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv6.conf.eno1.autoconf=0
net.ipv6.conf.eno1.accept_ra=2
net.ipv6.conf.default.forwarding=1
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.default.proxy_ndp=1
net.ipv6.conf.all.proxy_ndp=1

接着继续配置 PVE 网卡文件信息

1
vim /etc/network/interfaces
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
auto lo
iface lo inet loopback

iface eno1np0 inet manual

auto vmbr0
iface vmbr0 inet static
address 43.248.187.227/24
gateway 43.248.187.1
bridge-ports eno1np0
bridge-stp off
bridge-fd 0

# 物理网卡 vmbr0 配置一般不做改动
# 为虚拟机新建一个虚拟网桥 vmbr1
# 内网地址 192.168.100.1 虚拟机的网关
auto vmbr1
iface vmbr1 inet static
address 192.168.100.1
netmask 255.255.255.0
bridge-ports none
bridge-stp off
bridge-fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up echo 1 > /proc/sys/net/ipv4/conf/eno1/proxy_arp
post-up iptables -t nat -A POSTROUTING -s '192.168.100.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.100.0/24' -o vmbr0 -j MASQUERADE

iface eno2np1 inet manual

iface eno3np2 inet manual

iface eno4np3 inet manual


source /etc/network/interfaces.d/*

重启网络服务

1
sudo service networking restart

安装 DHCP 服务(安装默认爆红无法启动,需要配置完成后才能启动)

1
apt install isc-dhcp-server
1
vim /etc/default/isc-dhcp-server

改成网卡

1
2
INTERFACESv4="vmbr1"
INTERFACESv6=""

接着修改配置

1
vim /etc/dhcp/dhcpd.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
option domain-name "lan";
option domain-name-servers 223.5.5.5, 8.8.8.8, 1.1.1.1;

default-lease-time 600;
max-lease-time 7200;
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.5 192.168.100.230;
option subnet-mask 255.255.255.0;
option domain-name-servers 223.5.5.5, 8.8.8.8, 1.1.1.1;
option domain-name "lan";
option routers 192.168.100.1;
option netbios-name-servers 192.168.100.1;
option netbios-node-type 8;
get-lease-hostnames true;
use-host-decl-names true;
default-lease-time 600;
max-lease-time 7200;
interface vmbr1;
}

注意 domain-namedomain-name-servers 可以和母机一直以防止 DNS 无法链接

通过 cat /etc/resolv.conf 在母机上查询 DNS 配置

通常返回以下结果

1
2
3
4
5
root@pve:~# cat /etc/resolv.conf
search lan
nameserver 223.5.5.5
nameserver 8.8.8.8
nameserver 1.1.1.1

重启 DHCP 服务

1
systemctl restart isc-dhcp-server

查询 DHCP 服务状态

1
systemctl status isc-dhcp-server

安装 rinetd

1
apt install rinetd

使用 iptables 配置端口映射

1
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 30022 -j DNAT --to-destination 192.168.100.5:22

删除只需要把新增映射的 -A 改成 -D 即可

1
iptables -t nat -D PREROUTING -p tcp -m tcp --dport 30022 -j DNAT --to-destination 192.168.100.5:22

查看NAT规则,并显示行号

1
iptables -t nat --list --line-number

至此已经可以正常使用了

Exposed DSL 中 deleteWhere 无法识别 eq 操作符

起因

代码中使用了 Exposed DSL 中的 deleteWhere 方法,但是在使用 eq 操作符时,编译器提示找不到 eq 方法。

Unresolved reference ‘eq’.

1
2
3
4
5
transaction {
PetSoulInstanceTable.deleteWhere {
PetSoulInstanceTable.identifier eq identifier
}
}

只需要手动导入

1
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq;

非 root 用户安装 Tmux 终端

Tmux 终端是一个很好用的终端复用器 他可以启动一系列的会话 窗口 窗格 每个都是独立的存在

安装

root 用户安装仅需一行

1
sodu apt-get install tmux

root 用户就不一样了 需要下载源码手动编译

下载

下载tmux及其依赖软件。

1
2
3
wget -c https://github.com/tmux/tmux/releases/download/3.5a/tmux-3.5a.tar.gz
wget -c https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
wget -c https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz

解压

1
2
3
tar -xzvf tmux-3.5a.tar.gz
tar -xzvf libevent-2.1.12-stable.tar.gz
tar -xzvf ncurses-6.4.tar.gz

构建依赖

先安装 libevent-2.1.12-stable 依赖

1
cd libevent-2.1.12-stable
1
2
./configure --prefix=/home/替换成你的用户名/local --disable-shared
make && make install

接着退出当前目录

1
cd ..

再安装 ncurses-6.4 依赖

1
cd ncurses-6.4
1
2
./configure --prefix=/home/替换成你的用户名/local
make && make install

退出当前目录 依赖安装完成

1
cd ..

构建本体

1
2
3
cd tmux-3.5a
./configure --prefix=/home/替换成你的用户名/local CFLAGS="-I/home/替换成你的用户名/local/include -I/home/替换成你的用户名/local/include/ncurses" LDFLAGS="-L/home/替换成你的用户名/local/lib -L/home/替换成你的用户名/local/include/ncurses -L/home/替换成你的用户名/local/include"
make && make install

如果没什么错误并且在当前目录下生成了 tmux 就成功构建了 将 tmux 文件复制出去使用即可

configure 可能会出现以下错误 原因缺少词法分析器 就我们去手动编译安装一下词法分析器

1
2
checking for yacc... no
configure: error: "yacc not found"

下载解压

1
2
wget https://ftp.gnu.org/gnu/bison/bison-3.2.1.tar.gz
tar -xzvf bison-3.8.tar.gz

进入目录配置编译安装一下

1
2
3
cd bison-3.8.tar.gz
./configure --prefix=/home/替换成你的用户名/local
make && make install

配置 bison 时可能会出现以下报错 原因是系统未安装 M4 可以去手动编译安装一下

1
2
3
4
checking for GNU M4 that supports accurate traces... configure: error: no acceptable m4 could be found in $PATH.
GNU M4 1.4.6 or later is required; 1.4.16 or newer is recommended.
GNU M4 1.4.15 uses a buggy replacement strstr on some systems.
Glibc 2.9 - 2.12 and GNU M4 1.4.11 - 1.4.15 have another strstr bug.
1
2
wget https://mirrors.kernel.org/gnu/m4/m4-1.4.19.tar.gz
tar -xzvf m4-1.4.19.tar.gz

继续进入目录配置编译安装一下

1
2
3
cd bison-3.8.tar.gz
./configure --prefix=/home/替换成你的用户名/local
make && make install

安装完成返回 bison 目录进行编译安装

配置用户运行目录

如果还是提示未找到 M4 可以配置一下用户的 bin 目录

1
2
3
vim ~/.bashrc
export PATH=$PATH:/home/替换成你的用户名/local/bin
source ~/.bashrc

然后再次执行配置编译 bison 然后到 tmux 目录执行编译安装

如果没有配置用户运行目录则需要将编译出来的 tmux 复制出去使用或者使用路径全称使用 /home/替换成你的用户名/local/bin/tmux

个人主页

🤣 之前一直用的别人的模板改了一下临时顶了一下当主页使用,今天也是心血来潮了一下试着自己用 Vue 搓一个 个人主页

由于自己没什么审美直接用 Vue 的初始模板改了改,由于没有前端基础耗时四五个小时,也算是草草了事了~

现在访问 WCPE’s Home Page ☝️ 应该能看到了

Gitlab 备份

数据备份

使用命令 gitlab-backup create 进行备份的创建

示例输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Dumping database tables:
- Dumping table events... [DONE]
- Dumping table issues... [DONE]
- Dumping table keys... [DONE]
- Dumping table merge_requests... [DONE]
- Dumping table milestones... [DONE]
- Dumping table namespaces... [DONE]
- Dumping table notes... [DONE]
- Dumping table projects... [DONE]
- Dumping table protected_branches... [DONE]
- Dumping table schema_migrations... [DONE]
- Dumping table services... [DONE]
- Dumping table snippets... [DONE]
- Dumping table taggings... [DONE]
- Dumping table tags... [DONE]
- Dumping table users... [DONE]
- Dumping table users_projects... [DONE]
- Dumping table web_hooks... [DONE]
- Dumping table wikis... [DONE]
Dumping repositories:
- Dumping repository abcd... [DONE]
Creating backup archive: <backup-id>_gitlab_backup.tar [DONE]
Deleting tmp directories...[DONE]
Deleting old backups... [SKIPPING]

备份路径 /var/opt/gitlab/backups 会出现一个类似 1736266336_2025_01_07_17.4.2_gitlab_backup.tar 的文件

数据恢复

复制文件到 /var/opt/gitlab/backups 并修改文件权限

1
2
sudo cp 1736266336_2025_01_07_17.4.2_gitlab_backup.tar /var/opt/gitlab/backups/
sudo chown git:git /var/opt/gitlab/backups/1736266336_2025_01_07_17.4.2_gitlab_backup.tar

使用命令先停止数据库连接

1
2
3
4
sudo gitlab-ctl stop puma
sudo gitlab-ctl stop sidekiq
# Verify
sudo gitlab-ctl status

然后使用命令

1
sudo gitlab-backup restore BACKUP=1736266336_2025_01_07_17.4.2

其中 1736266336_2025_01_07_17.4.2 这段为备份文件名称前段

Gradle 插件测试

在项目的 settings.gradle.kts 可以直接引入插件发布的 Maven 仓库

1
2
3
4
5
6
7
pluginManagement {
repositories {
mavenLocal()
maven("https://maven.wcpe.top/repository/maven-public/")
gradlePluginPortal()
}
}

build.gradle.kts 中可以直接引用插件

1
2
3
plugins {
id("top.wcpe.corebridge") version "1.0.0"
}

2024 年度总结

简单小结

去过了很多地方

相比于 2023 年,在 2024 这一年我又独自去了挺多地方的,在 2023 月底时我独自从 杭州 第一次坐上了飞机前往了 天津 这座城市与我的好朋友跨年,并且同时和一位网友面基了一下,也对 天津 这座城市有了一段难忘了回忆。

随后在农历新年到来之际的前几天我又独自前往了 江苏 扬州 与另一位网友再次面基 :> 随后游览了 瘦西湖中国大运河博物馆 和几个本地的小吃街并尝试了闻名已久的 淮扬菜

在过完了农历新年之后我又紧接着马不停蹄的赶往了 湖北 武汉 打卡了 古德寺黄鹤楼 等著名景点

随后回到杭州正式上班了之后由于工作地点变动又从 杭州 搬往了 温州 苍南 这么一个新鲜的地方,在休息空闲之余又与同事前往周围 龙港市区温州市区苍南168黄金海岸线炎亭景区渔寮景区洞头区 等等沿海岸边游览了一遍。

待到五月假期寻找附近的地方继续游览,上边部分地区已经去过了便定在了下边 福建 于是一路向南 按照 柘荣-鸳鸯草场霞浦-宁德市区福州市区 最终抵达 平潭

到了七月份因为我抢到了 邓紫棋 在福州开办的 《邓紫棋 "I Am Gloria" 世界巡回演唱会》 我便又前往 福州市 这是我第一次看演唱会,并且还是我最喜欢的 邓紫棋 ,上万人的热情加上当时 30℃ 左右的高温非常的红令我十分难忘。

自从上次演唱会看完之后我迷上了演唱会一样,在附近的喜欢我都想抢上一抢,就在这么一种着魔的状态下我在九月份又前往 福州市 观看了 《张杰 未·LIVE 开往 1982 巡回演唱会》 虽然部分歌曲不熟悉甚至没听过,到时到了经典的 逆战着魔 等等歌曲时候,还是喊到脑袋缺氧了。

到了十月份,我先前抢到的 《JJ 20 世界巡回演唱会》 厦门站 也迎来了日子我便安排调休一共三天前往 厦门市 游玩并观看演唱会,此次又见识了大城市的繁华和 鼓浪屿 这种小岛的松弛感。

学会了很多东西

对于自己的编程能力也是提升很大的一年,也学会了很多,认识到了很多自己的不足之处

首先经历了长达一个多月的对线上 MySQL 数据库 JVM 服务问题排查调优等锻炼

也算是熟悉了部分工具的使用方法,其中我觉得最好用的莫过于阿里巴巴开源的 Arthas 帮助我方便的解决了很多线上问题

其他还有像 Jdk 带的如 jmap 等工具也非常不错

其中尤其对 多线程方面的知识欠缺得到了补充

等等等

(未完)?Bushi 我懒得写了哈哈哈哈

构建 Folia

准备构建 https://github.com/PaperMC/Folia 这个项目的 1.21.1 版本

clone 项目下来知道 gradle 换到 jdk21 即可同步项目

然后根据文档给出的构建方式

1
./gradlew applyPatches
1
./gradlew createMojmapPaperclipJar

直接报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
> Task :paper:patchCraftBukkit FAILED
Execution failed for task ':paper:patchCraftBukkit'.
> io.papermc.paperweight.PaperweightException: Command finished with 128 exit code: git -c commit.gpgsign=false -c core.safecrlf=false clone --no-hardlinks C:\XXX\Folia\.gradle\caches\paperweight\upstreams\paper\work\CraftBukkit C:\XXX\Folia\.gradle\caches\paperweight\upstreams\paper\.gradle\caches\paperweight\taskCache\patchCraftBukkit.repo

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. 为什么
BUILD FAILED in 14s
2 actionable tasks: 2 executed

尝试了开全魔法环境, 重装 Git 等操作都没有用

于是我就把命令复制出来手动运行一遍 结果

git 最大只可以创建 4096 长度的文件名 然而在 Windows 只有 260 得改配置

1
git config --global core.longpaths true

直接再次运行 补丁成功

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
19:03:33: Executing 'applyPatches'…


> Configure project :
paperweight-patcher v1.7.1 (running on 'Windows 11')

> Task :clonePaperRepo

> Configure project :paper
paperweight-core v1.7.1 (running on 'Windows 11')

> Task :paper:initSubmodules
> Task :paper:patchSpigotApiPatches UP-TO-DATE
> Task :paper:patchSpigotApi UP-TO-DATE
> Task :paper:applyApiPatches UP-TO-DATE
> Task :paper:downloadMcManifest
> Task :paper:downloadMcVersionManifest UP-TO-DATE
> Task :paper:downloadServerJar UP-TO-DATE
> Task :paper:extractFromBundler UP-TO-DATE
> Task :paper:addAdditionalSpigotMappings UP-TO-DATE
> Task :paper:downloadMappings UP-TO-DATE
> Task :paper:filterVanillaJar UP-TO-DATE
> Task :paper:generateMappings UP-TO-DATE
> Task :paper:generateSpigotMappings UP-TO-DATE
> Task :paper:spigotRemapJar UP-TO-DATE
> Task :paper:cleanupMappings UP-TO-DATE
> Task :paper:patchMappings UP-TO-DATE
> Task :paper:cleanupSourceMappings UP-TO-DATE
> Task :paper:remapJar UP-TO-DATE
> Task :paper:fixJar UP-TO-DATE
> Task :paper:patchCraftBukkitPatches UP-TO-DATE
> Task :paper:filterSpigotExcludes UP-TO-DATE
> Task :paper:spigotDecompileJar UP-TO-DATE
> Task :paper:patchCraftBukkit UP-TO-DATE
> Task :paper:patchSpigotServerPatches UP-TO-DATE
> Task :paper:patchSpigotServer UP-TO-DATE
> Task :paper:patchSpigot UP-TO-DATE
> Task :paper:downloadSpigotDependencies UP-TO-DATE
> Task :paper:collectAtsFromPatches UP-TO-DATE
> Task :paper:mergePaperAts UP-TO-DATE
> Task :paper:remapSpigotSources UP-TO-DATE
> Task :paper:remapGeneratedAt UP-TO-DATE
> Task :paper:remapSpigotAt UP-TO-DATE
> Task :paper:mergeGeneratedAts UP-TO-DATE
> Task :paper:mergeAdditionalAts UP-TO-DATE
> Task :paper:applyMergedAt UP-TO-DATE
> Task :paper:copyResources UP-TO-DATE
> Task :paper:decompileJar UP-TO-DATE
> Task :paper:downloadMcLibrariesSources UP-TO-DATE
> Task :paper:applyServerPatches UP-TO-DATE
> Task :paper:applyPatches UP-TO-DATE
> Task :paper:lineMapJar UP-TO-DATE
> Task :paper:prepareForDownstream
> Task :getPaperUpstreamData

> Task :applyApiPatches
Creating Folia-API from patch source...
Applying patches to Folia-API...
5 patches applied cleanly to Folia-API

> Task :applyGeneratedApiPatches
Creating generated from patch source...
Applying patches to generated...
No patches found

> Task :applyServerPatches
Creating Folia-Server from patch source...
Importing 23 classes from vanilla...
Importing 0 data files from vanilla...
Importing 0 classes from library sources...
Applying patches to Folia-Server...
18 patches applied cleanly to Folia-Server

> Task :applyPatches

BUILD SUCCESSFUL in 1m 10s
5 actionable tasks: 5 executed
19:04:44: Execution finished 'applyPatches'.

直接运行 createMojmapPaperclipJar 开始构建 Jar 包

Gitlab 迁移后的文件权限问题

起因

我的 RockyLinux 9 100G 硬盘分区不够用了我给他进行了扩容操作 然后经过一系列脑瘫操作之后成功的把 lvm 卷搞丢了 我就准备迁移数据重装一个 Linux 系统 于是选择了 Debian 12

经过我的不懈努力安装完成了 Debian12 装上了 1panel 面板之后 把数据通过 sync 迁移过去之后 发现 gitlab 仓库无法进行 pull push 等操作 都会提示

1
2
17:23:52.302: [ProjectName] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master --tags
fatal: unable to access 'https://git.example.top/wcpeplugin/ProjectName.git/': Error while processing content unencoding: invalid stored block lengths

最后在 gitlab issue 中找到了解决方案

https://gitlab.com/gitlab-org/charts/gitlab/-/issues/5546

codissimo1 @codissimo1

I had the same problem Error while processing content unencoding: invalid stored block lengths when upgrading gitlab-ee (ubuntu repository package) from 16.11.2 to 17.2.1

It turned out: some files in /var/opt/gitlab/git-data/repositories had owner = root.

Solution:

find /var/opt/gitlab/git-data/repositories -exec chown git:git {} ;

Thanks to @pks-gitlab

没错 只需要进入 gitlab-ce docker 容器中 输入 find /var/opt/gitlab/git-data/repositories -exec chown git:git {} \; 将权限修正即可