fix: default router with fakeIP when tun enable

This commit is contained in:
MetaCubeX 2022-05-04 00:36:44 +08:00
parent 41adfa65b3
commit 6cd5769ed7

View file

@ -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,7 +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 {
if err = execRouterCmd("add", addr.String(), interfaceName, ip.String(), "main"); err != nil {
return err
}