Last active
March 20, 2024 13:40
-
-
Save sjtosco/01f2fa5461ce65f936ca4d40c1c6caa8 to your computer and use it in GitHub Desktop.
Check router (gateway) of specific interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get_gw_by_iface(){ | |
# Return router ip of interface | |
# Usage: get_gw_by_iface IFACE | |
sudo traceroute -n -i $1 -m1 $(get-extip) 2>/dev/null | tail -1 | awk '{print $2}' | |
} | |
get_gw_by_iface2(){ | |
# Return router ip of interface (multitable) | |
# Usage: get_gw_by_iface IFACE | |
ip route list table all | awk '/default via/' | grep enp1s0 | awk '{print $3}' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment