Skip to content

Commit 6fb6473

Browse files
authored
feat: add docker ipv6 support (#45)
1 parent d7d33e1 commit 6fb6473

File tree

3 files changed

+68
-22
lines changed

3 files changed

+68
-22
lines changed

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- [tinyPortMapper](https://github.com/wangyu-/tinyPortMapper)
1919
- [Prometheus Node Exporter](https://github.com/leishi1313/node_exporter)
2020

21-
目前,全部端口转发功能均已支持 `IPV6` ,如果中转机器本身同时具备 `IPV4``IPV6` 网络访问能力,可以借助端口转发实现 `IPV4 to IPV6``IPV6 to IPV4`
21+
目前,全部端口转发功能均已支持 `IPV6` 。除 `iptables` 以外的转发方式,如果中转机器本身同时具备 `IPV4``IPV6` 网络访问能力,可以借助端口转发实现 `IPV4 to IPV6``IPV6 to IPV4`
2222

2323
### 面板服务器与被控机说明
2424

@@ -40,6 +40,15 @@
4040
- CPU 架构
4141
- [x] AMD64
4242
- [x] ARM64
43+
- 网络类型
44+
- [x] IPV4
45+
- [X] IPV6
46+
47+
特别说明:由于 docker 默认不开启 IPV6,如果需要在面板通过 IPV6 连接被控机 SSH,请在面板机器使用 `ip6tables` 命令为容器添加 IPV6 NAT:
48+
49+
```shell
50+
ip6tables -t nat -A POSTROUTING -s fd00:ea23:9c80:4a54:e242:5f97::/96 -j MASQUERADE
51+
```
4352

4453
#### 中转机器(被控机)支持进度:
4554

@@ -56,6 +65,9 @@
5665
- CPU 架构
5766
- [x] AMD64
5867
- [x] ARM64
68+
- 网络类型
69+
- [x] IPV4
70+
- [X] IPV6
5971
- Linux init process
6072
- [x] systemd
6173
- [ ] SysVinit
@@ -70,6 +82,8 @@
7082
```shell
7183
bash <(curl -fsSL https://raw.githubusercontent.com/Aurora-Admin-Panel/deploy/main/install.sh)
7284
# 国内机器安装可以选择使用 fastgit 镜像
85+
# 但由于拉取 docker 镜像时候默认服务器仍在国外,可能拉取速度较慢
86+
# 可自行搜索如何配置 Docker Hub 国内镜像加速
7387
# bash <(curl -fsSL https://raw.fastgit.org/Aurora-Admin-Panel/deploy/main/install.sh) --mirror
7488
```
7589

docker-compose.yml

+23
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ services:
1515
- app-data:/app/ansible/priv_data_dirs
1616
depends_on:
1717
- redis
18+
networks:
19+
- aurora
20+
- worker
1821

1922
backend:
2023
image: leishi1313/aurora-admin-backend:latest
@@ -31,6 +34,8 @@ services:
3134
depends_on:
3235
- postgres
3336
- redis
37+
networks:
38+
- aurora
3439

3540
nginx:
3641
image: leishi1313/aurora-admin-frontend:latest
@@ -41,12 +46,16 @@ services:
4146
- 8000:80
4247
depends_on:
4348
- backend
49+
networks:
50+
- aurora
4451

4552
redis:
4653
image: redis
4754
restart: always
4855
environment:
4956
TZ: 'Asia/Shanghai'
57+
networks:
58+
- aurora
5059

5160
postgres:
5261
image: postgres:13-alpine
@@ -58,8 +67,22 @@ services:
5867
POSTGRES_DB: aurora
5968
volumes:
6069
- db-data:/var/lib/postgresql/data
70+
networks:
71+
- aurora
6172

6273

6374
volumes:
6475
db-data:
6576
app-data:
77+
78+
networks:
79+
worker:
80+
enable_ipv6: true
81+
driver: bridge
82+
ipam:
83+
driver: default
84+
config:
85+
- subnet: fd00:ea23:9c80:4a54:e242:5f97::/96
86+
gateway: fd00:ea23:9c80:4a54:e242:5f97::0
87+
aurora:
88+
driver: bridge

install.sh

+30-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#! /bin/bash
22

3-
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
3+
[[ $EUID != 0 ]] && echo -e "${Error} 请使用 root 账号运行该脚本!" && exit 1
4+
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
5+
6+
Green_font_prefix="\033[32m"
7+
Green_background_prefix="\033[42;37m"
8+
Red_font_prefix="\033[31m"
9+
Red_background_prefix="\033[41;37m"
10+
Font_color_suffix="\033[0m"
411
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
512
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
613
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"
@@ -21,26 +28,25 @@ while [[ $# -ge 1 ]]; do
2128
esac
2229
done
2330

24-
if [[ $(curl -m 10 -s https://api.ip.sb/geoip | grep 'China') != "" ]]; then
25-
echo -e "${Tip} 根据 ip.sb 提供的信息,当前 IP 可能在中国"
26-
read -e -r -p "是否选用镜像完成安装? [Y/n] " input
27-
case $input in
28-
[yY][eE][sS] | [yY])
29-
echo -e "${Tip} 使用中国镜像"
30-
FASTGIT="镜像加速"
31-
;;
32-
[nN][oO] | [nN])
33-
echo -e "${Tip} 不使用中国镜像"
34-
;;
35-
*)
36-
echo "使用中国镜像"
37-
FASTGIT="镜像加速"
38-
;;
39-
esac
31+
if curl --version > /dev/null 2>&1; then
32+
if [[ -n $(curl -m 5 -s https://api.ip.sb/geoip | grep "China") ]]; then
33+
echo -e "${Tip} 根据 ip.sb 提供的信息,当前 IP 可能在中国"
34+
read -e -r -p "是否选用 fastgit 镜像完成安装? [Y/n] " input
35+
case $input in
36+
[yY][eE][sS] | [yY])
37+
echo -e "${Tip} 使用 github 镜像加速 ..."
38+
FASTGIT="镜像加速"
39+
;;
40+
[nN][oO] | [nN])
41+
;;
42+
*)
43+
;;
44+
esac
45+
fi
4046
fi
4147

42-
[[ $EUID != 0 ]] && echo -e "${Error} 请使用 root 账号运行该脚本!" && exit 1
43-
48+
INSTALL_VERSION="1.0.0"
49+
[[ -z "$HOME" ]] && echo -e "${Error} 家目录检查失败!" && exit 1
4450
AURORA_HOME="$HOME/aurora"
4551
AURORA_HOME_BACKUP="$HOME/aurora_backup"
4652
AURORA_DOCKER_YML=${AURORA_HOME}/docker-compose.yml
@@ -210,6 +216,9 @@ function install() {
210216
read_port
211217
echo_config
212218
echo "-----------------------------------"
219+
[[ ! -d "$HOME"/.ssh ]] && mkdir -p "$HOME"/.ssh
220+
# avoid docker creating a directory automatically
221+
[[ ! -f "$HOME"/.ssh/id_rsa ]] && touch "$HOME"/.ssh/id_rsa
213222
docker-compose up -d && docker-compose exec backend python app/initial_data.py && \
214223
(echo -e "${Info} 极光面板安装成功,已启动!" && exit 0) || (echo -e "${Error} 极光面板安装失败!" && exit 1)
215224
}
@@ -237,7 +246,7 @@ function update() {
237246
(echo -e "${Info} 极光面板更新成功!" && exit 0) || (echo -e "${Error} 极光面板更新失败!" && exit 1)
238247
}
239248

240-
function backup_data_after_uninstall(){
249+
function backup_data_before_uninstall(){
241250
if [ ! -d ${AURORA_HOME_BACKUP} ]; then
242251
mkdir ${AURORA_HOME_BACKUP}
243252
fi
@@ -250,7 +259,7 @@ function uninstall() {
250259
[ -f ${AURORA_DOCKER_YML} ] || (echo -e "${Tip} 未检测到已经安装极光面板!" && exit 0)
251260
[[ -n $(docker ps | grep aurora | grep postgres) ]] && \
252261
echo -e "${Tip} 正在备份数据库,如果意外卸载请重新安装面板并恢复数据库!" && backup
253-
backup_data_after_uninstall
262+
backup_data_before_uninstall
254263
cd ${AURORA_HOME}
255264
[[ -n $(docker ps | grep aurora) ]] && docker-compose down
256265
OLD_IMG_IDS=$(docker images | grep aurora | awk '{ print $3; }')

0 commit comments

Comments
 (0)