ginuerzh/gost · error
%s: %v
Error message
%s: %v
What it means
On macOS, createTun configures the newly created TUN interface by shelling out to ifconfig ('ifconfig <ifc> inet <addr> <peer> mtu <mtu> up'). If exec.Command(...).Run() fails, the error is wrapped as '<full command>: <underlying error>' and returned from createTun, aborting TUN creation.
Source
Thrown at tuntap_darwin.go:41
if err != nil {
return
}
mtu := cfg.MTU
if mtu <= 0 {
mtu = DefaultMTU
}
peer := cfg.Peer
if peer == "" {
peer = ip.String()
}
cmd := fmt.Sprintf("ifconfig %s inet %s %s mtu %d up",
ifce.Name(), cfg.Addr, peer, mtu)
log.Log("[tun]", cmd)
args := strings.Split(cmd, " ")
if er := exec.Command(args[0], args[1:]...).Run(); er != nil {
err = fmt.Errorf("%s: %v", cmd, er)
return
}
if err = addTunRoutes(ifce.Name(), cfg.Routes...); err != nil {
return
}
itf, err = net.InterfaceByName(ifce.Name())
if err != nil {
return
}
conn = &tunTapConn{
ifce: ifce,
addr: &net.IPAddr{IP: ip},
}
return
}View on GitHub (pinned to a33fdbf4c9)
Solutions
- Run the process with elevated privileges (sudo) so ifconfig can configure the interface
- Validate cfg.Addr/peer values and the ifce.Name() returned by the TUN device open
- Run the failing ifconfig command manually to see the raw error
- Check that the utun device was created successfully before configuration
Example fix
// before $ ./gost -L 'tun://...' # fails: ifconfig ... : operation not permitted // after $ sudo ./gost -L 'tun://...'
Defensive patterns
Strategy: try-catch
Validate before calling
// check privileges before attempting TUN setup
if os.Geteuid() != 0 {
return errors.New("creating a TUN interface on macOS requires root")
} Try / catch
ifce, err := createTun(cfg)
if err != nil {
if strings.Contains(err.Error(), "ifconfig") {
return fmt.Errorf("tun setup failed (are you root?): %w", err)
}
return err
} Prevention
- Run macOS TUN services with sudo/root
- Validate tun address/peer/mtu config values before startup
- Test the generated ifconfig command manually when it fails
- Ensure the utun device opens successfully before configuration
When it happens
Trigger: Starting a TUN-based service on macOS where the ifconfig command fails — typically because the process lacks root privileges, the interface vanished, or the address/peer arguments are invalid.
Common situations: Running the app without sudo (macOS TUN setup requires root); missing or invalid tun.address/tun.netmask/peer config; ifconfig not present or PATH issues; OS denying utun operations.
Related errors
- %s: %v
- accept on closed listener
- listener has been closed
- not a packet connection
- tap is not supported on darwin
AI-assisted analysis of ginuerzh/gost@a33fdbf4c9 (2026-09-02).
Data as JSON: /api/errors/eac0c5c830636260.
Report an issue: GitHub.