Open In App

Which Command is Used to View the IP Address and Default Gateway of a Computer?

Last Updated : 11 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Answer: The command used to view the IP address and default gateway of a PC is `ipconfig` on Windows and `ip route` or `ifconfig` on Linux/Unix/MacOS systems.

To view the IP address and default gateway of a PC, the command differs by operating system:

Windows

Use `ipconfig` in Command Prompt. It displays network interfaces. Find the `IPv4 Address` for the IP address and `Default Gateway` for the gateway.

macOS/Linux

Use `ifconfig` for macOS or `ip addr show` for Linux in Terminal for IP addresses. For the default gateway, use `netstat -nr` for macOS or `ip route` for Linux.

Conclusion: Accessing a PC’s IP address and default gateway is simple. Windows users should employ `ipconfig`, while macOS and Linux users can rely on `ifconfig` or `ip addr show` for IP details, and `netstat -nr` or ip route for gateway information. These commands are crucial for network diagnostics and configuration, providing a quick way to retrieve network connection details.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads