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

Add DNS routes #1943

Merged
merged 39 commits into from
Jun 4, 2024
Merged

Add DNS routes #1943

merged 39 commits into from
Jun 4, 2024

Conversation

lixmal
Copy link
Contributor

@lixmal lixmal commented May 7, 2024

Describe your changes

This PR adds DNS routes.

Given domains are resolved periodically and resolved IPs are replaced with the new ones. Unless the flag keep_route is set to true, then only new ones are added.
This option is helpful if there are long-running connections that might still point to old IP addresses from changed DNS records.

This feature is not yet ready to catch changes from resolvers that use round-robin DNS.

Example route creation

api_url="http://localhost:8080/api"
api_token=xxx
peer_group_id=xxx
group_id=xxx

curl -X POST "$api_url/routes" \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $api_token" \
    --data-raw '{
      "description": "",
      "network_id": "dns-route",
      "enabled": true,
      "peer_groups": [
        "'$peer_group_id'"
      ],
      "domains": [
        "netbird.io",
        "www.netbird.io",
        "google.com",
        "ipinfo.io"
      ],
      "keep_route": true,
      "metric": 9999,
      "masquerade": true,
      "groups": [
        "'$group_id'"
      ]
    }'
}'

Viewing resolved IPs
Currently resolved IPs can be viewed by running

netbird routes ls

Example output:

Available Routes:

  - ID: dns-route
    Domains: netbird.io, www.netbird.io, google.com
    Status: Selected
    Resolved IPs:
      [netbird.io]: 2a05:d014:1f8d:7302:ebca:ec15:b24d:d07e, 18.158.22.172
      [www.netbird.io]: 2a05:d014:1f8d:7302:ebca:ec15:b24d:d07e, 18.158.22.172
      [google.com]: 172.217.161.46, 2404:6800:4004:825::200e, 172.217.161.78, 142.251.42.142, 2404:6800:4004:80b::200e, 2404:6800:4004:80a::200e, 2404:6800:4008:c06::8b, 2404:6800:4008:c06::8a, 2404:6800:4008:c06::65, 2404:6800:4008:c06::66, 142.251.222.14, 2404:6800:4004:80f::200e

Status
Routes can be tracked via netbird status -d as usual:

On the client:

Peers detail:
 router1.netbird.cloud:
  NetBird IP: 100.64.117.193
  Public key: AcqMAbqyU0/rWxLpOXvMyg3z2bVA8GnMeqONEMN6ejo=
  Status: Connected
  -- detail --
  Connection type: P2P
  Direct: true
  ICE candidate (Local/Remote): host/host
  ICE candidate endpoints (Local/Remote): 192.168.141.1:51820/172.16.127.130:51820
  Last connection update: 21 minutes, 31 seconds ago
  Last WireGuard handshake: 1 minute ago
  Transfer status (received/sent) 148 B/31.5 KiB
  Quantum resistance: false
  Routes: 1.1.1.1/32, netbird.io, www.netbird.io, google.com
  Latency: 1.891443ms

On the routing peer:

OS: linux/amd64
Daemon version: development
CLI version: development
Management: Connected to http://api.netbird.io:443
Signal: Connected to https://signal.netbird.io:443
Relays:
  [stun:turn.stage.netbird.io:3478] is Available
  [turns:turn.stage.netbird.io:3478?transport=tcp] is Available
Nameservers:
FQDN: router1.netbird.cloud
NetBird IP: 100.64.117.193/16
Interface type: Kernel
Quantum resistance: false
Routes: 1.1.1.1/32, netbird.io, www.netbird.io, google.com
Peers count: 1/1 Connected

Issue ticket number and link

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

@lixmal lixmal marked this pull request as ready for review May 19, 2024 11:00
@nazarewk
Copy link
Contributor

Not digging into the details (maybe it's here), but it's worth watching out for resolving DNS names on the Peer doing the routing from within the network.

@lixmal lixmal force-pushed the feature/dns-routes branch from b5b12b0 to b5912ce Compare May 31, 2024 11:56
@lixmal lixmal force-pushed the feature/dns-routes branch from 81b93e2 to 129f515 Compare June 3, 2024 12:41
Copy link

sonarqubecloud bot commented Jun 3, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
31 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
3.2% Duplication on New Code

See analysis details on SonarCloud

@lixmal lixmal merged commit ee79f6c into 0.28.0 Jun 4, 2024
24 checks passed
@lixmal lixmal deleted the feature/dns-routes branch June 4, 2024 11:41
lixmal added a commit that referenced this pull request Jun 7, 2024
lixmal added a commit that referenced this pull request Jun 7, 2024
mlsmaycon added a commit that referenced this pull request Jun 13, 2024
* compile client under freebsd (#1620)

Compile netbird client under freebsd and now support netstack and userspace modes.
Refactoring linux specific code to share same code with FreeBSD, move to *_unix.go files.

Not implemented yet:

Kernel mode not supported
DNS probably does not work yet
Routing also probably does not work yet
SSH support did not tested yet
Lack of test environment for freebsd (dedicated VM for github runners under FreeBSD required)
Lack of tests for freebsd specific code
info reporting need to review and also implement, for example OS reported as GENERIC instead of FreeBSD (lack of FreeBSD icon in management interface)
Lack of proper client setup under FreeBSD
Lack of FreeBSD port/package

* Add DNS routes (#1943)

Given domains are resolved periodically and resolved IPs are replaced with the new ones. Unless the flag keep_route is set to true, then only new ones are added.
This option is helpful if there are long-running connections that might still point to old IP addresses from changed DNS records.

* Add process posture check (#1693)

Introduces a process posture check to validate the existence and active status of specific binaries on peer systems. The check ensures that files are present at specified paths, and that corresponding processes are running. This check supports Linux, Windows, and macOS systems.


Co-authored-by: Evgenii <[email protected]>
Co-authored-by: Pascal Fischer <[email protected]>
Co-authored-by: Zoltan Papp <[email protected]>
Co-authored-by: Viktor Liu <[email protected]>
Co-authored-by: Bethuel Mmbaga <[email protected]>
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 this pull request may close these issues.

3 participants