Skip to content

Commit 42b6218

Browse files
committed
Disable rp filter atomically
1 parent 3d16996 commit 42b6218

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tun_linux.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func New(options Options) (Tun, error) {
7373
options: options,
7474
}
7575
}
76+
nativeTun.disableReversePathFilter()
7677
return nativeTun, nil
7778
}
7879

@@ -1049,3 +1050,10 @@ func (t *NativeTun) setSearchDomainForSystemdResolved() {
10491050
_ = shell.Exec(ctlPath, append([]string{"dns", t.options.Name}, common.Map(dnsServer, netip.Addr.String)...)...).Run()
10501051
}()
10511052
}
1053+
1054+
func (t *NativeTun) disableReversePathFilter() {
1055+
_ = os.WriteFile("/proc/sys/net/ipv4/conf/all/rp_filter", []byte{'0'}, 0o644)
1056+
if t.options.Name != "" {
1057+
_ = os.WriteFile("/proc/sys/net/ipv4/conf/"+t.options.Name+"/rp_filter", []byte{'0'}, 0o644)
1058+
}
1059+
}

0 commit comments

Comments
 (0)