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

Error connect tunnel with KubeVPN when IPv6 disable. #244

Closed
leduyquy opened this issue May 13, 2024 · 15 comments · Fixed by #248
Closed

Error connect tunnel with KubeVPN when IPv6 disable. #244

leduyquy opened this issue May 13, 2024 · 15 comments · Fixed by #248

Comments

@leduyquy
Copy link

Hello.

I have setup KubeVPN for my cluster but when use kubectl connect to cluster with kubevpn plugin it show error can not setup ipv6. For my company policy, we must disable IPv6 on our computers and not enable it.

Is there any way we can setup a tunnel with kubevpn without enabling IPv6 on my PC?

Thank you.

@wencaiwulue
Copy link
Collaborator

wencaiwulue commented May 13, 2024

:> Hello.

I have setup KubeVPN for my cluster but when use kubectl connect to cluster with kubevpn plugin it show error can not setup ipv6. For my company policy, we must disable IPv6 on our computers and not enable it.

Is there any way we can setup a tunnel with kubevpn without enabling IPv6 on my PC?

Thank you.

@leduyquy can you provide some log, and which os you are using? macos/windows/linux

@leduyquy
Copy link
Author

Hi @whomobile

This is out put log when I connect with IPv6 disable.

image

I'm using Ubuntu 23.10

@wencaiwulue
Copy link
Collaborator

Hi @whomobile

This is out put log when I connect with IPv6 disable.

image

I'm using Ubuntu 23.10

got it, by the way. I am @wencaiwulue ...

@wencaiwulue
Copy link
Collaborator

wencaiwulue commented May 14, 2024

@leduyquy can you use the following code, and save to main.go, then run it with ·go run main.go·, and show the result? i want to detect if ipv6 is enabled ~ thanks in advance ~

package main

import (
    "fmt"
    "net"
    "os"
)

func main() {
    addrs, err := net.InterfaceAddrs()
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    ipv6Enabled := false
    for _, addr := range addrs {
        // Type assertion to net.IPNet to get the IP address without the mask.
        if ipNet, ok := addr.(*net.IPNet); ok && ipNet.IP.To16() != nil {
            if ipNet.IP.To4() == nil { // This is an IPv6 address
                ipv6Enabled = true
                break
            }
        }
    }

    if ipv6Enabled {
        fmt.Println("IPv6 is enabled on this system.")
    } else {
        fmt.Println("IPv6 is not enabled on this system.")
    }
}

@leduyquy
Copy link
Author

Hi @wencaiwulue

This is result

image

@wencaiwulue
Copy link
Collaborator

Hi @wencaiwulue

This is result

image

ok, got it, i will use this way to detect ipv6 is enable or not. thanks

@whomobile
Copy link
Contributor

whomobile commented May 14, 2024

Hi @wencaiwulue

ipv4, _, err = net.ParseCIDR(cfg.Addr6)

cfg.Addr instead of Addr6 ?

quick search https://github.com/search?q=repo%3Akubenetworks%2Fkubevpn%20net.ParseCIDR&type=code
show other platform use Addr

but it looks not root cause.
https://github.com/kubenetworks/kubevpn/blob/984ab2ce89d925352aeff79cbfda3fb89cf7d834/pkg/tun/tun_bsd.go#L62C3-L62C82

@wencaiwulue
Copy link
Collaborator

Hi @wencaiwulue

ipv4, _, err = net.ParseCIDR(cfg.Addr6)

cfg.Addr instead of Addr6 ?

quick search https://github.com/search?q=repo%3Akubenetworks%2Fkubevpn%20net.ParseCIDR&type=code show other platform use Addr

but it looks not root cause. https://github.com/kubenetworks/kubevpn/blob/984ab2ce89d925352aeff79cbfda3fb89cf7d834/pkg/tun/tun_bsd.go#L62C3-L62C82

Yes, bug 😂, maybe nobody using kubevpn on bsd system 😂😂😂

@wencaiwulue
Copy link
Collaborator

@leduyquy commit: #248 can you pull this branch code, and make kubevpn manually? github attachment max size is 50Mb😂

@wencaiwulue
Copy link
Collaborator

wencaiwulue commented May 14, 2024

Hi @whomobile

ipv4, _, err = net.ParseCIDR(cfg.Addr6)

cfg.Addr instead of Addr6 ?

quick search https://github.com/search?q=repo%3Akubenetworks%2Fkubevpn%20net.ParseCIDR&type=code show other platform use Addr

but it looks not root cause. https://github.com/kubenetworks/kubevpn/blob/984ab2ce89d925352aeff79cbfda3fb89cf7d834/pkg/tun/tun_bsd.go#L62C3-L62C82

here is commit: #249, please take a review, thanks ~

@whomobile
Copy link
Contributor

maybe better check if ipv6 enabled from below.

Addr6: os.Getenv(config.EnvInboundPodTunIPv6),

also based on below. how come even that env var set the value if IPv6 is not enabled?
https://github.com/search?q=repo%3Akubenetworks%2Fkubevpn%20EnvInboundPodTunIPv6&type=code

It looks like below can be issue when IPv6 is not enabled.

innerIPv6Pool = "efff:ffff:ffff:ffff:ffff:ffff:ffff:9999/64"

@leduyquy
Copy link
Author

@leduyquy commit: #248 can you pull this branch code, and make kubevpn manually? github attachment max size is 50Mb😂

I testing with this branch it working, many thanks.

image

@wencaiwulue
Copy link
Collaborator

maybe better check if ipv6 enabled from below.

Addr6: os.Getenv(config.EnvInboundPodTunIPv6),

also based on below. how come even that env var set the value if IPv6 is not enabled? https://github.com/search?q=repo%3Akubenetworks%2Fkubevpn%20EnvInboundPodTunIPv6&type=code

It looks like below can be issue when IPv6 is not enabled.

innerIPv6Pool = "efff:ffff:ffff:ffff:ffff:ffff:ffff:9999/64"

Yes, you are right. If env ipv6 set, means wants to set ipv6 addr. Maybe better way is add flag --stack v4/v6/both/auto. when we connect to cluster. We can special this option. Set env var more early. Not so late when use it then to check.

@wencaiwulue
Copy link
Collaborator

wencaiwulue commented May 14, 2024

maybe better check if ipv6 enabled from below.

Addr6: os.Getenv(config.EnvInboundPodTunIPv6),

also based on below. how come even that env var set the value if IPv6 is not enabled? https://github.com/search?q=repo%3Akubenetworks%2Fkubevpn%20EnvInboundPodTunIPv6&type=code

It looks like below can be issue when IPv6 is not enabled.

innerIPv6Pool = "efff:ffff:ffff:ffff:ffff:ffff:ffff:9999/64"

@whomobile
I make some change: 14e421c

@wencaiwulue
Copy link
Collaborator

@leduyquy already release v2.2.9, you can have a try ~

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

Successfully merging a pull request may close this issue.

3 participants