在Docker中使用OpenVPN的IPv6

时间:2018-05-30 08:40:31

标签: docker ipv6 openvpn

我正在尝试在运行IPv6的docker容器(alpine:3.7)中获取OpenVPN。当OpenVPN主机不发送任何IPv6信息时,它可以正常工作。当它为我的连接发送IPv6地址时,我收到以下错误:

[...]
Wed May 30 08:32:20 2018 TUN/TAP device tun0 opened
Wed May 30 08:32:20 2018 TUN/TAP TX queue length set to 100
Wed May 30 08:32:20 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=1
Wed May 30 08:32:20 2018 /sbin/ip link set dev tun0 up mtu 1500
Wed May 30 08:32:20 2018 /sbin/ip addr add dev tun0 10.4.1.112/16 broadcast 10.4.255.255
Wed May 30 08:32:20 2018 /sbin/ip -6 addr add fde6:7a:7d20:4::116e/64 dev tun0
RTNETLINK answers: Permission denied
Wed May 30 08:32:20 2018 Linux ip -6 addr add failed: external program exited with error status: 2
Wed May 30 08:32:20 2018 Exiting due to fatal error

我正在用

启动我的docker容器
sudo docker run -it --name container --cap-add=NET_ADMIN --device=/dev/net/tun myimage

任何想法,我必须添加哪些特权才能使其正常工作?

1 个答案:

答案 0 :(得分:1)

哦,我自己找到了解决方案:

必须通过设置sysctl值为容器启用IPv6:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: SRCarouselOrderTableViewCell.cellIdentifier, for: indexPath) as! SRCarouselOrderTableViewCell
        cell.configureCell(name: displayedOrderList[indexPath.row].name!, image: (categoryEnum(rawValue: displayedOrderList[indexPath.row].category!)?.getIconCategory())!)
        return cell
}

因此,没有上述问题的启动容器的最终命令是:

func tableView(_: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
    let movedObject = displayedOrderList[sourceIndexPath.row]

    displayedOrderList.remove(at: sourceIndexPath.row)
    hiddenOrderList.insert(movedObject, at: destinationIndexPath.row)
}