Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webssh无法连接ipv6机器,显示:connect: cannot assign requested address #152

Open
AndersonGhost opened this issue Nov 28, 2023 · 5 comments

Comments

@AndersonGhost
Copy link

1.安装服务的机器物理ip支持ipv4和ipv6,系统为Debian11,版本为5.10.0-23-amd64。

2.配置docker支持ipv6:使用如下方法配置docker使其支持ipv6.
编辑 /etc/docker/daemon.json ,加上以下内容。(如果没有这个文件直接创建。)
{
"ipv6": true,
"fixed-cidr-v6": "fd00::/80",
"experimental": true,
"ip6tables": true
}
重启docker engine
sudo systemctl restart docker
测试
sudo docker run --rm -it busybox ping -6 -c4 ipv6-test.com
sudo docker run --rm -it busybox ifconfig
显示如下:
image

3.使用搭建好的webssh连接纯ipv6的小鸡,显示如下:connect: cannot assign requested address
image
image

@AndersonGhost
Copy link
Author

AndersonGhost commented Nov 28, 2023

搭建方法为:docker-compose up -d
其中,docker-compose.yml的内容如下:

version: '3.3'
services:
    sshwifty:
        restart: always
        ports:
            - '8090:8182'             # 8090可以改成任意服务器没有使用过的端口,8182不要修改
        container_name: sshwifty
        image: 'niruix/sshwifty:latest'

@nirui
Copy link
Owner

nirui commented Nov 28, 2023

如果你用的是docker-compose的话,除了打开Docker的IPv6支持,还需要在docker-compose.yaml里指定容器的IPv6地址,否则容器里的程序会无法在建立SOCKET的时候正确的取得本地网络接口(这也是导致connect: cannot assign requested address错误的原因)。

具体来说,你可以按照下面的样例修改你的docker-compose.yaml

version: '3.3'
services:
  sshwifty:
    restart: always
    ports:
      - '8090:8182'
    container_name: sshwifty
    image: 'niruix/sshwifty:latest'
    networks:
      sshwifty-network:
        ipv6_address: ... #在这里指定容器的IPv6地址

networks:
  sshwifty-network:
    enable_ipv6: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: ... #在这里指定容器的IPv6子网/段
          gateway: ... #这里指定IPv6网关地址

详见 https://stackoverflow.com/a/45577278

@AndersonGhost
Copy link
Author

如果使用docker 一键安装,如何开启ipv6呢?使用什么命令呢?docker-compose还是挺麻烦的

@nirui
Copy link
Owner

nirui commented Nov 28, 2023

如果你是通过docker run ...的方式部署Sshwifty(见:https://github.com/nirui/sshwifty/blob/master/README.md#docker-image ),那么只要Docker打开了IPv6支持即可,因为docker run会使用默认的bridge network( https://docs.docker.com/config/daemon/ipv6/#use-ipv6-for-the-default-bridge-network )。

@AndersonGhost
Copy link
Author

感谢大佬!成功了!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants