背景
- Docker中Host网络无法获取IPV6地址,无法侦听IPV6,故导致在公网无法正常访问容器内的资源(纯IPV6)。
- 扒贴无数,并无很好的解决方案。这个方法虽然繁琐,但还算是有用吧。
工具
- Entware
- socat(Linux下的瑞士军刀)
过程
安装Entware
懒得汉化了。
Deploying Entware
1. Create a folder on your hdd (outside rootfs)
mkdir -p /volume1/@Entware/opt
2. Remove /opt
and mount optware folder
Make sure that /opt
folder is empty (Optware is not installed), we will remove /opt
folder with its contents at this step.
rm -rf /opt
mkdir /opt
mount -o bind "/volume1/@Entware/opt" /opt
Note : if the bind command doesn't work, try to create a link instead :
ln -s /volume1/@Entware/opt/ /opt
3. Run install script depending on the processor (uname -m to know)
- for armv8 (aarch64) - Realtek RTD129x
wget -O - http://bin.entware.net/aarch64-k3.10/installer/generic.sh | /bin/sh
- for armv5
wget -O - http://bin.entware.net/armv5sf-k3.2/installer/generic.sh | /bin/sh
- for armv7
wget -O - http://bin.entware.net/armv7sf-k3.2/installer/generic.sh | /bin/sh
- for x64
wget -O - http://bin.entware.net/x64-k3.2/installer/generic.sh | /bin/sh
4. Create Autostart Task
Create a triggered user-defined task in Task Scheduler.
- Goto: DSM > Control Panel > Task Scheduler
- Create > Triggered Task > User Defined Script
- General
- Task: Entware
- User: root
- Event: Boot-up
- Pretask: none
- Task Settings
- Run Command: (see bellow)
- General
#!/bin/sh
# Mount/Start Entware
mkdir -p /opt
mount -o bind "/volume1/@Entware/opt" /opt
/opt/etc/init.d/rc.unslung start
# Add Entware Profile in Global Profile
if grep -qF '/opt/etc/profile' /etc/profile; then
echo "Confirmed: Entware Profile in Global Profile"
else
echo "Adding: Entware Profile in Global Profile"
cat >> /etc/profile <<"EOF"
# Load Entware Profile
. /opt/etc/profile
EOF
fi
# Update Entware List
/opt/bin/opkg update
6. Reboot your NAS.
安装socat
/opt/bin/opkg install socat
使用
进行转发测试
socat TCP6-LISTEN:1234,reuseaddr,fork TCP4:127.0.0.1:6800 &
- 添加计划任务
虽然比较麻烦,还好达成了目的。值得注意的是最后命令中两个端口不能一致。