# assuming ipv4, or else we might need to deal with multiple addresses
# in an ipv4 + ipv6 network.
my_ip=$(ip -4 route get 8.8.8.8 | sed -nr 's,^.*src\s+(\S+).*,\1,p')
# assuming ipv4, or else we might need to deal with multiple addresses
# in an ipv4 + ipv6 network.
my_ip=$(ip -4 route get 8.8.8.8 | sed -nr 's,^.*src\s+(\S+).*,\1,p')