Last active
February 27, 2024 14:24
-
-
Save sysbitnet/3e50a007d8083c01a73d2bee23ffd570 to your computer and use it in GitHub Desktop.
Get Public IP # Create a simple script to fetch your public IP address using the dig command. If you're using a Unix-like system (Linux or macOS), you can create a bash script.
This file contains 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
#!/bin/bash | |
# Fetch public IP address using dig and OpenDNS resolver | |
ip_address=$(dig +short myip.opendns.com @resolver1.opendns.com) | |
# Print the public IP address | |
echo "Your public IP address is: $ip_address" | |
# Save this script in a file, for example, get_public_ip.sh. Make it executable using the following command: chmod +x get_public_ip.sh | |
# Run the script by executing: ./get_public_ip.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment