gravitl / netclient

Apache License 2.0
66 stars 30 forks source link

Netclient keeps added routes after disconnected #351

Open imightbelosthere opened 1 year ago

imightbelosthere commented 1 year ago

netclient v0.18.6 installed with service running and everything properly configured as far as I can see, however the Egress node routes published upon connection established do not get removed after disconnection. This causes the machine to lose connectivity to the IP ranges published by the Egress node when the netclient is not connected.

lexermal commented 1 year ago

netclient 0.21.0 behaves the same way. It's a pain. I try to connect to some hosts in the same local area network but can't because Netmaker only works with hosts with a different public IP. So I need to write a script for always leaving the Netmaker network and deleting all host entries when I'm in my home network where my server is located.

Please fix that or make Netmaker work over local area networks.

lexermal commented 12 months ago

I found a solution. You simply need to create a bridge over the Netmaker server. When I want to access a host in my network over the DNS name like I would by being connected to a network from Netmaker I use the DNS server from Netmaker as local DNS server and connect to Netmaker via Wireguard.

This is how I did it:

  1. Setup Netmaker on a VPS.
  2. Add a network.
  3. Create an access token for that network and copy it
  4. Add the following to the docker-compose.yml file and add the token:
  netclient:
    container_name: netclient-dns-server
    image: 'gravitl/netclient:v0.21.0'
    network_mode: "service:coredns"
    depends_on:
      - coredns
    restart: always
    privileged: true
    environment:
      TOKEN: my-token
    volumes:
      - ./netclient-data:/etc/netclient
  1. Start up the server again.
  2. Now a new host with a cryptic name joined the network. Rename it to a fitting name and copy its IP.
  3. Create a gateway in Netmaker in that network and set the default DNS server to the copied IP.
  4. Connect a device via Wireguard.

Now you can access all hosts in that network over the DNS name like you would with Netclient if you were behind another NAT.