From e9bd2d8d68149acdda5d3f1d5c271b4199fa12a3 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Wed, 4 May 2022 00:36:44 +0800 Subject: [PATCH] fix: default router with fakeIP when tun enable --- listener/tun/ipstack/commons/router_linux.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/listener/tun/ipstack/commons/router_linux.go b/listener/tun/ipstack/commons/router_linux.go index af14d481..6f1b6f51 100644 --- a/listener/tun/ipstack/commons/router_linux.go +++ b/listener/tun/ipstack/commons/router_linux.go @@ -17,9 +17,10 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, var ( interfaceName = dev.Name() ip = addr.Masked().Addr().Next() + err error ) - if _, err := cmd.ExecCmd(fmt.Sprintf("ip addr add %s dev %s", ip.String(), interfaceName)); err != nil { + if _, err = cmd.ExecCmd(fmt.Sprintf("ip addr add %s dev %s", ip.String(), interfaceName)); err != nil { return err } @@ -27,9 +28,7 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, return err } - if err = execRouterCmd("add", addr, interfaceName, "198.18.0.1", "main"); err != nil { - return err - } + execRouterCmd("add", addr.String(), interfaceName, ip.String(), "main") if autoRoute { err = configInterfaceRouting(interfaceName, addr, autoDetectInterface)