Add support for IPv6 CIDR ranges as subnets #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ipv6"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://github.com/skx/simple-vpn/issues/12
A /64 subnet has 2^64 IP addresses which is way too many
to fit in-memory for the simple-vpn server. To add IPv6
support, we initialize the server with at-most 2^20 IPs
which translates to a /108 subnet. If we run out of IPs
in the /108, we expand the subnet to /107 and so on.
Thanks for your submission.
I've had a quick look and it looks good, but I'll want to test it over the weekend before I'm sure.
(e.g. Do we need to add "-6" to the IP commands? I don't think so, but will need to test to be sure.)
Sounds good. I did some basic testing
socaton the client interface and sent some packets to it usingtelnetIt's definitely a good idea to do some testing of your own to be sure.
Yeah that's the kind of thing I'd do, but I'd connect and reconnect a number of machines and see that the IP-allocation makes sense. No leaks or gaps.
Also test the static assignment via name too.
OK, I think there's something else that needs to be done to setup routing correctly with
ip. I created 2 IPv6 clients and tried to send TCP packet from one to the other and it did not work. There's definitely something missing. I'll take a lookProbably worth checking the IP commands that get run.
Or exploring via the cli
ip routeip addrprobably need an-6adding to them. The MTU and others will be OK without it I think. I'll explore tonight/tomorrow if you don't manage to see what the problem is before then.I tried
-6on theip route/addrand that didn't seem to make a difference. I'm connecting to the server websocket over an IPv4 interface. I don't think that should make a difference but maybe that's what's breaking itI launched the server with this configuration-file:
The server launches and it shows:
Looks like the initial IP is bogus - notice how
fefe::is shown? Rather than "fefe::1".Same with the client. When the client connects the remote IP of the master is shown as "fefe::"
To fix this manually you could, on the master run:
On the client something like this:
In short you're not allocating/iterating over the IPs correctly to assign the first to the master, and later ones to each client.
Does that help?
I don't think that's the issue. For IPv6,
fde4:8dba:82e1:fefe::just meansfde4:8dba:82e1:fefe:0000:0000:0000:0000. The0address is assigned to the server in this case. That's a reserved address in IPv4 but not in IPv6.Just in case that was the issue, I tried assigning
fde4:8dba:82e1:fefe:0000:0000:0000:0001to the server andfde4:8dba:82e1:fefe:0000:0000:0000:0002andfde4:8dba:82e1:fefe:0000:0000:0000:0003to the clients by skipping the0address. That still didn't work.Good correction :)
Something wrong there. I don't expect client1<->master to work, nor client2<->master, but client1<->client2 should, and won't if they have the same IP.
For reproducibility, I'm running the server on an ubuntu 18.04 VM in virtual box and running the clients in docker containers on the same VM.
Client.cfg
vpn = ws://localhost:9000Here's my Dockerfile for the client:
To build:
docker build --rm -f "Dockerfile" -t simple-vpn:latest .To run:
docker run --rm -it --cap-add=NET_ADMIN --sysctl net.ipv6.conf.all.disable_ipv6=0 simple-vpn:latestRun the client:
./simple-vpn client ./etc/client.cfgThanks for the overview; I'm using real hosts. You've gotten me curious now, and I will be attacking this myself later in the day.
But I see nothing wrong with saying "max 256/1024 clients". Doing that will cut down on the allocations I think. I'll concentrate on the IP allocation, and I hope if/when that is right it'll just work.
OK I'm happy with #15 to allocate IPs better.
Routing fails. Looks like
shared/socketHandler.goneeds updating.This is annoying and harder than it needs to be :/
I'd be curious to know what needs to be updated in
socketHandler.go. That was pretty much what I noticed as well irrespective of how allocation works.See the last commit on #15; results in a working system.
Of course its a hack ..
How about using https://github.com/songgao/water/blob/master/waterutil/tun.go to determine if the packet is v4 or v6 and then extracting the mac address based on that?
Yup that works.
Sorry for the duplication, and I do appreciate your contribution but I'm going to close this PR now, and keep going with my own. If you could test it that would be useful, and good.
Closing, in favor of #15, but thank-you.
Pull request closed