分类目录归档:技术笔记

dnsmasq 多网卡分网段配置

在 dnsmasq 的配置文件 /etc/dnsmasq.conf 中使用类似下面的配置:

bind-interfaces
dhcp-range=eth1,10.192.10.50,10.192.10.200,12h
dhcp-range=eth2,10.192.20.50,10.192.20.200,12h
dhcp-range=eth3,10.192.30.50,10.192.30.200,12h
dhcp-option=option:dns-server,119.29.29.29

接口实现一个 dnsmasq 实例,同时在多张网卡启动 DHCP 服务,并分配不同网段的 IP 地址。

AutoGPT 用法

git clone https://github.com/Torantulino/Auto-GPT.git
cd 'Auto-GPT'
pip install -r requirements.txt
# Rename .env.template to .env and fill in your OPENAI_API_KEY. If you plan to use Speech Mode, fill in your ELEVEN_LABS_API_KEY as well.
python scripts/main.py
# You will find activity and error logs in the folder ./output/logs
python scripts/main.py --debug

References

apt 查看软件库中软件包所有可用版本

要查看软件库中现有的所有可用版本,您可以使用以下命令:

apt-cache madison <package-name>

<package-name> 替换为您要查看版本信息的软件包名称。此命令将显示所有可用版本的软件包及其详细信息,包括软件包名称、版本号、发行版、构建日期和软件源等信息。

例如,要查看 Node.js 的所有可用版本,请使用以下命令:

apt-cache madison nodejs

此命令将显示所有可用版本的 Node.js 软件包及其详细信息。

您还可以使用以下命令来查看软件包的详细信息,包括其依赖项、描述、文件列表等:

apt-cache show <package-name>

例如,要查看 Node.js 的详细信息,请使用以下命令:

apt-cache show nodejs

此命令将显示 Node.js 软件包的详细信息,包括其依赖项、描述、文件列表等。

希望这些命令可以帮助您查看软件库中现有的所有可用版本。

判断 IP 或端口被封(墙)

IP 检测

命令行方式

最简单的是在命令行窗口上测试

$ ping x.x.x.x.

在线方式

可使用网站 Ping检测 进行测试

判断

  • 如果国内和国外都 ping 不通,则是海外服务器的问题
  • 如果国内 ping 不通,国外能 ping 通,那么 IP 被封了

端口检测

命令行方式

使用 telnet 命令测试端口:

# 可以直接测试 IP 或域名
$ telnet ip port

# 成功举例
telnet bus1.skybyte.me 443
Trying 104.243.19.12...
Connected to bus1.skybyte.me.
Escape character is '^]'.

# 失败举例
telnet x.x.x.x 500
Trying x.x.x.x...
telnet: connect to address x.x.x.x: Connection refused
telnet: Unable to connect to remote host

在线方式

判断

  • 如果国内和国外都不能连通,是服务器问题
  • 如果国内不能连通,国外能连通,那么端口被封了

References

Ubuntu 安装指定版本 docker

如果你过去安装过 docker,先删掉:

sudo apt-get remove docker docker-engine docker.io containerd runc

首先安装依赖:

sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common

信任 Docker 的 GPG 公钥并添加仓库: 发行版

sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirror.nju.edu.cn/docker-ce/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

安装最新

sudo apt-get update
sudo apt-get install docker-ce

安装指定版本

首选查看都有哪些版本可选

apt-cache madison docker-ce | awk '{ print $3 }'

选择版本并安装

# 以 5:20.10.13~3-0~ubuntu-jammy 为例
VERSION_STRING=5:20.10.13~3-0~ubuntu-jammy

sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin

Reference

debmirror 镜像 nexus3 apt 仓库

nexus3 没有很好的目录重命名方法。

使用 apt-mirror 镜像会出错,实测 debmirror 没问题。下面记录方法:

首先导入公钥

导入 apt 公钥

如果你已经有了公钥文件(如 public.key),你可以使用以下命令将其导入到 GPG 密钥环和 APT 的受信任密钥列表中:

  1. 导入 GPG 密钥到密钥环:
gpg --import public.key
  1. 查找密钥 ID。在导入密钥后,gpg 将显示类似于以下内容的输出:
gpg: key 1234567890ABCDEF: public key "Your Name <your.email@example.com>" imported

在这个示例中,1234567890ABCDEF 是密钥 ID。

  1. 将 GPG 公钥导出到 APT 的受信任密钥列表中:
gpg --export --armor 1234567890ABCDEF | sudo tee /etc/apt/trusted.gpg.d/1234567890ABCDEF.gpg

1234567890ABCDEF 替换为你的 GPG 密钥 ID。

现在,你已经成功地将公钥导入到 GPG 密钥环和 APT 的受信任密钥列表中。在使用 aptdebmirror 时,它们应该能够验证签名的仓库。

镜像仓库

为了使用 debmirror 镜像你的 Nexus3 APT 仓库,请按照以下步骤操作:

  1. 首先确保你已经安装了 debmirror。在基于 Debian/Ubuntu 的系统上,可以使用以下命令安装:
sudo apt-get install debmirror
  1. 在运行 debmirror 之前,首先确保已经导入了 GPG 密钥。你可以使用以下命令导入密钥:

见上一步。

  1. 运行 debmirror 命令,指定仓库地址、发行版、组件和架构等参数。这里是一个示例命令:
debmirror --host=192.168.25.8:8081 \
    --root=repository/test-apt-host \
    --method=http --progress --dist=bullseye \
    --section=main --arch=arm64 \
    --rsync-extra=none \
    --ignore-release-gpg ./pve-arm/

这个命令将从 http://192.168.25.8:8081/repository/test-apt-host 镜像别名为 bullseye 的发行版中 arm64 架构的相关 apt 包到本地的 ./apt-arm/ 目录。

根据需求,可以修改这些参数。

注意:--ignore-release-gpg 参数会跳过 GPG 签名检查。在确认仓库是可信的情况下,可以使用此参数。

--rsync-extra=none 会跳过 rsync 下载额外文件。

  1. 等待 debmirror 完成镜像过程。这可能需要一段时间,具体取决于仓库的大小。

完成这些步骤后,你应该在本地 ./pve-arm/ 目录中找到镜像的仓库。如果遇到任何问题,请确保检查命令中的参数是否正确。