ianharrier / synology-scripts

Scripts for Synology DSM
MIT License
112 stars 34 forks source link

Fix TUNNEL_INTERFACE env when there are many interfaces with the same IP #31

Open mr-elamin opened 3 weeks ago

mr-elamin commented 3 weeks ago

Hi, my tunnel IP address is 10.1.0.2/24 the command:

ip addr | grep 10.1.0.2 | awk '{ print $NF }'

The output in my case would be:

inet 10.1.0.2/24 scope global tun0
inet 10.1.0.2/24 scope global tun1

This will result two values for the TUNNEL_INTERFACE

TUNNEL_INTERFACE=$(ip addr | grep 10.1.0.2 | awk '{ print $NF }') echo $TUNNEL_INTERFACE tun0 tun1

This will result the ping test to go through tun0 not through tun1 and the ping will fail. image

FIX: TUNNEL_INTERFACE=$(ip addr | grep 10.1.0.2 | awk 'END{ print $NF }') after the change: image