Skip to content

第五步 蜗居在lxc里的Alist和DDNS

cooip-jm edited this page Feb 27, 2024 · 7 revisions

开一个debian的LXC

lxc-create --name Alist --template download -- --dist debian --release bookworm --arch arm64 --server mirrors.bfsu.edu.cn/lxc-images
image

简单配置一下

nano /var/lib/lxc/Alist/config 

image

# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.arch = linux64

# Container specific configuration
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.rootfs.path = dir:/var/lib/lxc/Alist/rootfs
lxc.uts.name = Alist

# Network configuration
lxc.net.0.type = veth
lxc.net.0.link = vmbr0
lxc.net.0.flags = up

启动和进入后,配置一下源,并安装一些基础服务。

如果觉得这样重复性的动作太麻烦,可以配置一个基础的lxc

使用lxc-copy 进行克隆(复制)

lxc-start Alist 
lxc-attach Alist

换源

https://mirrors.bfsu.edu.cn/help/debian/
image
vi /etc/apt/sources.list
image

安装基础应用

apt update && apt upgrade -y && apt install -y  openssh-server nano cron curl wget apt-transport-https ca-certificates

配置SSHD

nano /etc/ssh/sshd_config

image

配置root密码

passwd

image

找一个花钱or不花钱的域名

image

拿到Token后 测试一下

curl http://v6.sync.afraid.org/u/你的token/

image

把它写入crontab

crontab -e

image image

具体时间自己写,上面例子是每5分钟上传一次。

接下来部署Alist

官方Wiki有一键脚本,能偷懒当然偷懒

喜欢手搓的,自行按照Wiki研读

https://alist.nn.ci/zh/guide/install/script.html

image

curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s install
image

根据提示,它给了一个乱七八糟的密码就用它吧

image

等域名解析成功,在浏览器访问你的域名:5244

image

image

获取本机IP V6 方法

ip a | grep 2408 |awk '{print $2}' | cut -d'/' -f1 | sed -n '1p'  ###联通
ip a | grep 2409 |awk '{print $2}' | cut -d'/' -f1 | sed -n '1p'  ###移动
ip a | grep 240e |awk '{print $2}' | cut -d'/' -f1 | sed -n '1p'  ###电信

Curl 上报方式

curl "http://上报地址&token=ABCefsaaafd&$(ip a | grep 2409 |awk '{print $2}' | cut -d'/' -f1 | sed -n '1p')"  ###按照服务商格式自行修改

额外的

API v2 supports these four URLs:

https://sync.afraid.org/u/<record-token>/?ip=<address>
https://sync.afraid.org/u/?u=<user>&p=<password>&h=<hostname>&ip=<address>
https://<user>:<password>@sync.afraid.org/u/?h=<hostname>&ip=<address> (basic auth)
https://<user>:<password>@sync.afraid.org/nic/update/?hostname=<hostname>&myip=<address> (basic auth)
sync.afraid.org only has an A record. To reach the update service via IPv6 you have to use v6.sync.afraid.org. Both hosts can update both record types (A or AAAA); the only difference is the auto-detected IP address if the &ip= query parameter is left out.

image

样例

https://v6.sync.afraid.org/u/<record-token>/?ip=$(ip a | grep 2408 |awk '{print $2}' | cut -d'/' -f1 | sed -n '1p')"

在cron里配置alist的自动更新

添加 每天凌晨3点5分更新一次

5 3 * * * curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s update

image

到这里就结束了

更多的操作,可以打开脑洞,IPV6资源很丰富,是LXC的绝配