Here is a small snippet to find outgoing IP of your Linux box.
1. To find the outgoing internal IP only
# ip route get 8.8.8.8 | head -1 | gawk '{ print $7 }'
2. To find the outgoing internal IP along with interface.
# ip route get 8.8.8.8 | head -1 | gawk '{ print $5,$7 }'
3. In-case if your system is connected to Internet, to find the outgoing external IP
# curl ifconfig.me
Note: In case if your system having public IP assigned then there is no difference between outgoing internal IP and external IP (both are same).
0 Comments