Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore linux error: File exists while add same route twice #747

Merged
merged 1 commit into from
Aug 22, 2021

Conversation

wencaiwulue
Copy link
Contributor

naison@naison-virtual-machine:~$ sudo ip route add 10.10.0.0/16 dev tun0
[sudo] password for naison: 
naison@naison-virtual-machine:~$ sudo ip route add 10.10.0.0/16 dev tun0
RTNETLINK answers: File exists
naison@naison-virtual-machine:~$ 

Linux如果重复添加相同路由,会报错已经存在,window和macOS不会报这样的错误。因此这里加上忽略已经存在的路由。

2021/08/21 11:19:21 tuntap_linux.go:40: [tun] ip link set dev tun0 mtu 1350
2021/08/21 11:19:21 tuntap_linux.go:47: [tun] ip address add 223.254.254.2/24 dev tun0
2021/08/21 11:19:21 tuntap_linux.go:54: [tun] ip link set dev tun0 up
2021/08/21 11:19:21 tuntap_linux.go:151: [tun] ip route add 10.10.0.0/16 dev tun0
2021/08/21 11:19:21 main.go:88: ip route add 10.10.0.0/16 dev tun0: file exists

@ginuerzh ginuerzh merged commit 8f08304 into ginuerzh:master Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants