Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Support for IPv6 subnets #12

Closed
Closed

Description

@samridh90

First of all, thanks for making this. This is a really interesting project.
I was wondering how hard it would be to support IPv6-only subnets. By the looks of it, only https://github.com/skx/simple-vpn/blob/master/cmd_server.go#L170 assumes IPv4 and that's because we treat it like a string instead of like an IP address.
The use-case is when using simple-vpn within another private subnet, using IPv6-only makes it easy to pick an IP block that won't clash with the rest of the subnet.
Would you be able to support this use-case? Open to PRs?

Activity

  1. skx commented on Feb 20, 2019

    @skx
    Owner

    I'd be open to a pull-request which allowed the CIDR range to be an IPv6 range, presumably within fd00::/8 as a /48 or /64.

    For example:

    subnet = fde4:8dba:82e1::/48
    

    or:

     subnet = fde4:8dba:82e1:fefe::/64
    

    Instead of:

     subnet = 10.137.248.0/24
    

    Ranges picked via the unique local address-ranges.

    I think there shouldn't be too many changes required, but I'd probably not make them alone.

  2. added
    questionFurther information is requested
    on Feb 20, 2019
  3. samridh90 commented on Feb 20, 2019

    @samridh90
    Author

    I was trying to setup the project locally and I get the following error when I try to get dependencies:

    $ go get ./...
    # simple-vpn
    ./cmd_server.go:285:11: tapConfig.Name undefined (type water.Config has no field or method Name)
    

    Did the water library change their interface for tapConfig? It might be worth using dep to lock down the dependencies to specific versions

  4. skx commented on Feb 20, 2019

    @skx
    Owner

    Works for me, on a fresh host:

    $ go get -u github.com/skx/simple-vpn
    $ cd go/src/github.com/skx/simple-vpn
    $ go build .
    $ ./simple-vpn version
    unreleased
    

    I'll assume you're on Linux, if you're not that might explain it. Otherwise I see you ran "go get ./...", but not "go build ..".

  5. samridh90 commented on Feb 20, 2019

    @samridh90
    Author

    Thanks for checking, what version of golang are you using? I'll ensure I'm using the same version.
    Edit: I'm on Mac OS X

  6. skx commented on Feb 20, 2019

    @skx
    Owner
      frodo ~ $ go version
      go version go1.11.4 linux/amd64
    
  7. skx commented on Feb 20, 2019

    @skx
    Owner

    Ahh Mac OS X is probably going to cause you some pain :/

    I see the same thing:

      frodo ~/go/src/github.com/skx/simple-vpn $ GOOS=darwin GOARCH=amd64 go build .
      ./cmd_server.go:285:11: tapConfig.Name undefined (type water.Config has no field or method Name)
    

    Looks like that's noted in the source:

  8. skx commented on Feb 20, 2019

    @skx
    Owner

    You'd need to switch to tun-based stuff instead of tap-based stuff, and I'm not sure how much would be required to change :/

  9. samridh90 commented on Feb 20, 2019

    @samridh90
    Author

    That's OK, I'll use a linux VM instead. Easy enough to switch

  10. samridh90 commented on Feb 21, 2019

    @samridh90
    Author

    Ha, hit an OOM trying to start the server using a relatively "small" subnet like subnet = fde4:8dba:82e1:fefe::/64 because it tried to create the assigned map with 2^64 entries 😆

    A couple of options to deal with this:

    1. Limit the size of IPv6 subnets that can be used to /108 (a million IPs should be OK?). I tested this, it works reasonably well. No OOMs.
    2. Lazily init the map, start with a max of X entries and then add more if you're out of unassigned IPs and there are IPs left in the subnet. This can still hit an OOM if you end up a with lot of clients though I don't imagine you're looking to support billions of clients.

    I think it's OK to call out the limitation and just use smaller subnets. What do you think?

  11. skx commented on Feb 21, 2019

    @skx
    Owner

    I think I'd go for the second choice, because people will assume /64s - that's the most common routed range for IPv6 after all. (Pretty much the same as using a /32.)

    So lazy allocation seems like it would make most sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址