Skip to content

Commit

Permalink
[client] Fix freebsd default routes (#3230)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixmal authored Jan 23, 2025
1 parent 69f48db commit aafa9c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
2 changes: 0 additions & 2 deletions client/iface/device/device_kernel_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ type TunKernelDevice struct {
}

func NewKernelDevice(name string, address WGAddress, wgPort int, key string, mtu int, transportNet transport.Net) *TunKernelDevice {
checkUser()

ctx, cancel := context.WithCancel(context.Background())
return &TunKernelDevice{
ctx: ctx,
Expand Down
13 changes: 0 additions & 13 deletions client/iface/device/device_usp_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package device

import (
"fmt"
"os"
"runtime"

log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/device"
Expand All @@ -32,8 +30,6 @@ type USPDevice struct {
func NewUSPDevice(name string, address WGAddress, port int, key string, mtu int, iceBind *bind.ICEBind) *USPDevice {
log.Infof("using userspace bind mode")

checkUser()

return &USPDevice{
name: name,
address: address,
Expand Down Expand Up @@ -134,12 +130,3 @@ func (t *USPDevice) assignAddr() error {

return link.assignAddr(t.address)
}

func checkUser() {
if runtime.GOOS == "freebsd" {
euid := os.Geteuid()
if euid != 0 {
log.Warn("newTunUSPDevice: on netbird must run as root to be able to assign address to the tun interface with ifconfig")
}
}
}
5 changes: 5 additions & 0 deletions client/iface/freebsd/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ func (l *Link) setAddr(ip, netmask string) error {
return fmt.Errorf("set interface addr: %w", err)
}

cmd = exec.Command("ifconfig", l.name, "inet6", "fe80::/64")
if out, err := cmd.CombinedOutput(); err != nil {
log.Debugf("adding address command '%v' failed with output: %s", cmd.String(), out)
}

return nil
}

Expand Down

0 comments on commit aafa9c6

Please sign in to comment.