From 37053e95ec1d07673d20a974da6dd4917edb3cde Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 3 May 2022 23:28:02 +0800 Subject: [PATCH] chore: add default router 198.18.0.0/16 when tun enable --- listener/tun/ipstack/commons/router_linux.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/listener/tun/ipstack/commons/router_linux.go b/listener/tun/ipstack/commons/router_linux.go index 5fa5d79a..8464e140 100644 --- a/listener/tun/ipstack/commons/router_linux.go +++ b/listener/tun/ipstack/commons/router_linux.go @@ -19,13 +19,15 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, ip = addr.Masked().Addr().Next() ) - _, err := cmd.ExecCmd(fmt.Sprintf("ip addr add %s dev %s", ip.String(), interfaceName)) - if err != nil { + if _, err := cmd.ExecCmd(fmt.Sprintf("ip addr add %s dev %s", ip.String(), interfaceName)); err != nil { return err } - _, err = cmd.ExecCmd(fmt.Sprintf("ip link set %s up", interfaceName)) - if err != nil { + if _, err = cmd.ExecCmd(fmt.Sprintf("ip link set %s up", interfaceName)); err != nil { + return err + } + + if err = execRouterCmd("add", "198.18.0.0/16", interfaceName, "198.18.0.1", "main"); err != nil { return err }