Skip to content

Commit b86a658

Browse files
committed
fix(lower): windows ip routing
1 parent 3f654de commit b86a658

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lower/tun_windows.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,24 @@
33

44
package lower
55

6-
import "net"
6+
import (
7+
"net"
8+
"strconv"
9+
)
710

811
func (n *NICIO) Up() {
912
execute("cmd", "/c", "netsh interface ip set address name=\""+n.ifce.Name()+"\" source=static addr=\""+n.ip.String()+"\" mask=\""+(net.IP)(n.subnet.Mask).String()+"\" gateway=none")
1013
execute("cmd", "/c", "netsh interface ipv4 set subinterface \""+n.ifce.Name()+"\" mtu="+n.mtu)
14+
iface, err := net.InterfaceByName(n.ifce.Name())
15+
if err != nil {
16+
panic(err)
17+
}
1118
for _, c := range n.cidrs {
1219
ip, cidr, err := net.ParseCIDR(c)
1320
if err != nil {
1421
panic(err)
1522
}
16-
execute("cmd", "/c", "route ADD "+ip.String()+" MASK "+(net.IP)(cidr.Mask).String()+" "+n.ip.String())
23+
execute("cmd", "/c", "route ADD "+ip.String()+" MASK "+(net.IP)(cidr.Mask).String()+" "+n.ip.String()+" IF "+strconv.Itoa(iface.Index))
1724
}
1825
}
1926

0 commit comments

Comments
 (0)