
IP address lookup commands: Learn to distinguish local, gateway and public egress IP addresses and inspect interface and route information using native commands. This guide explains what each command does, its syntax, practical examples, useful options, and common mistakes. Commands are shown for typical installations; flags can vary across operating-system and tool versions.
Before you start
Open a terminal appropriate for the operating system shown in the examples. Check that the required tool is installed and that you are running it with the permissions needed for your task. Replace sample names, paths, hostnames and IDs with values from your own environment.
Syntax at a glance
Square brackets usually indicate optional arguments, while uppercase words such as FILE, HOST and PACKAGE are placeholders that you replace. Keep quotes around paths or text that contains spaces. Commands should be tested on a safe sample before being used in production.
Quick command reference
| Command | What it does | Example | Useful options |
|---|---|---|---|
ip addr / ipconfig | Inspect local interface addresses | ipconfig /all | Windows and Linux use different command families |
curl api.ipify.org | Query a service for the public egress IP | curl -s https://api.ipify.org | Alternative services exist; network proxy/VPN changes the visible egress address |
ip route get | Determine the route selected for a destination | ip route get 1.1.1.1 | Linux-specific; use route print on Windows |
route print | Display Windows IPv4/IPv6 routing tables | route print -4 | -4/-6 filters address family |
nslookup | Resolve a host to DNS address records | nslookup example.com | Use an explicit server to compare results |
Command syntax and examples explained
1. ip addr / ipconfig
Purpose: Inspect local interface addresses.
Syntax
ip addr showExample
ipconfig /allOptions and notes: Windows and Linux use different command families.
Private IPs identify a local network interface and are not the same as public IPs.
2. curl api.ipify.org
Purpose: Query a service for the public egress IP.
Syntax
curl https://api.ipify.orgExample
curl -s https://api.ipify.orgOptions and notes: Alternative services exist; network proxy/VPN changes the visible egress address.
This sends a request to a third-party service; do not use it in privacy-sensitive environments without review.
3. ip route get
Purpose: Determine the route selected for a destination.
Syntax
ip route get ADDRESSExample
ip route get 1.1.1.1Options and notes: Linux-specific; use route print on Windows.
It identifies the selected local interface/gateway, not the entire internet path.
4. route print
Purpose: Display Windows IPv4/IPv6 routing tables.
Syntax
route printExample
route print -4Options and notes: -4/-6 filters address family.
Do not alter routes unless you understand the network impact.
5. nslookup
Purpose: Resolve a host to DNS address records.
Syntax
nslookup NAMEExample
nslookup example.comOptions and notes: Use an explicit server to compare results.
DNS answers can return multiple addresses and are not a geolocation guarantee.
Common mistakes and troubleshooting
- Command not found: confirm the tool is installed and available on your PATH; open a new terminal after changing PATH.
- Permission denied: verify the current account, file permissions and target path. Use administrator/root privileges only when genuinely required.
- Unexpected output: check the command version, quoting, current directory and exact arguments. Consult the local help or manual for options supported by your build.
- Destructive operations: preview the target and keep a backup before deleting data, rewriting history, flashing a partition or changing system configuration.
Safety tips
Review every command before running it, especially commands that delete files, change permissions, flash firmware, alter a database or expose a network service. For network scanning and remote administration, work only on devices and systems you own or are authorized to test. Keep credentials, private keys, access tokens and log files private.
Frequently asked questions
Do these commands work on every system?
Not always. Some commands are specific to Windows, Linux, Android, a particular package manager or an installed tool version. Use the syntax shown for your platform and check local help when a flag is unavailable.
Can I copy and run every example exactly?
Use the examples as templates. Replace placeholders such as filenames, package IDs, hostnames and paths with your own values, and verify the effect before executing a command that changes data or system state.
Conclusion
Use this reference as a starting point, then confirm flags in the tool’s official help or manual for your installed version. A clear understanding of syntax, options and side effects makes command-line work more reliable.