Developer & Network Tools

ipconfig, ifconfig and ip: Reading Your Network Setup

Find your IP address, gateway and DNS servers on Windows, macOS and Linux, and read the results.

Key takeaways

  • Windows uses ipconfig, macOS commonly uses ifconfig plus a few helpers, and modern Linux uses ip.
  • The four facts to find are your address, prefix or mask, default gateway and DNS servers.
  • An IPv4 address starting with 169.254 usually means automatic configuration from the network failed.
  • Several interfaces and addresses are normal, especially with IPv6, VPNs and virtual machines.
  • The addresses shown on your computer are often private ones, not the address websites see.

To see how your computer is connected, run ipconfig /all on Windows, ifconfig on macOS, or ip address and ip route on Linux. Those commands show your IP addresses, the subnet you're on, the gateway that leads elsewhere and, with a little help, the DNS servers you're using.

Knowing how to read that output answers many questions before you touch a router: Did you get an address at all? Are you on the network you think you are? Where is your traffic going first?

The four things to look for

IP address: your interface's identity on this network. Subnet mask or prefix length: which other addresses count as local. Default gateway: the router that receives traffic for everywhere else. DNS servers: the resolvers that turn names into addresses.

What a working network setup includes
Your interface Wi-Fi or Ethernet adapter MAC address Hardware address on the link DNS servers Turn names into addresses IP address Identifies you locally Prefix or mask Marks what is local Default gateway Way out of the network Your interface Wi-Fi or Ethernet adapter IP address Identifies you locally Prefix or mask Marks what is local Default gateway Way out of the network DNS servers Turn names into addresses MAC address Hardware address on the link

Most home devices receive the first four automatically from the router through DHCP. IPv6 can also configure addresses from router announcements.

Windows: ipconfig

Open Command Prompt or PowerShell and run:

ipconfig
ipconfig /all

The short form lists each adapter with its addresses and gateway. The long form adds the physical (MAC) address, whether DHCP is enabled, lease times, the DHCP server and DNS servers.

A trimmed, hypothetical result looks like this:

Wireless LAN adapter Wi-Fi:
   IPv4 Address. . . . . . . . . . . : 192.168.1.34
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1
   DNS Servers . . . . . . . . . . . : 192.168.1.1

Adapters marked "Media disconnected" aren't in use. Virtualization software and VPNs add their own entries, so find the adapter that matches how you're actually connected.

Other useful switches:

ipconfig /release
ipconfig /renew
ipconfig /flushdns
ipconfig /displaydns

/release gives up the DHCP lease and /renew asks for one again. /flushdns clears the local resolver cache, which flushing your DNS cache discusses in more detail. Releasing an address over a remote desktop session cuts you off, so don't do it from afar.

PowerShell also offers Get-NetIPConfiguration and Get-NetIPAddress, which return structured objects you can filter in scripts.

macOS: ifconfig and friends

ifconfig
ifconfig en0
ipconfig getifaddr en0
netstat -rn
scutil --dns

ifconfig lists every interface. en0 is often Wi-Fi on a Mac laptop, but numbering varies by model and adapters, so check which one is active. lo0 is the loopback interface.

Look for lines beginning inet (IPv4) and inet6 (IPv6). The mask may appear in hexadecimal, such as 0xffffff00, which means 255.255.255.0. status: active indicates a live link.

The macOS ipconfig command is a different program from the Windows one. ipconfig getifaddr en0 prints just the IPv4 address, and ipconfig getpacket en0 shows the DHCP reply the interface received. netstat -rn shows the routing table, including the default route, and scutil --dns shows resolver settings. System Settings shows the same basics graphically, with menu names that vary by version.

Linux: the ip command

Many Linux distributions treat ifconfig as legacy and may not install it. The ip command from the iproute2 package replaces it.

ip address
ip -brief address
ip link
ip route
ip -6 route
ip neigh

You can shorten these to ip a, ip r and ip n. ip -brief address gives one line per interface, which is usually what you want first.

In ip address output, interface names such as eth0, enp3s0 or wlan0 identify the adapter. Flags like UP and LOWER_UP show that it's enabled and has a link. Addresses appear with a prefix length, such as 192.168.1.34/24.

ip route shows where packets go:

default via 192.168.1.1 dev wlan0
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.34

The first line is the default gateway. The second says the local network is reached directly. ip neigh shows local neighbors and their hardware addresses, the table that ARP fills.

DNS settings depend on the distribution. Try resolvectl status where systemd-resolved is in use, or look at /etc/resolv.conf. If that file lists a loopback address, a local service is forwarding queries, and the real upstream servers are configured there.

Reading the routing table

The default gateway is only one line in a longer list. The routing table tells your computer which interface and next hop to use for each destination. On Windows, print it with route print or netstat -r. On macOS use netstat -rn, and on Linux use ip route.

When several entries match a destination, the most specific one wins, meaning the route with the longest prefix. A route for 192.168.1.0/24 beats the default route for any address inside that range. Between otherwise equal routes, a metric or priority value decides, and lower is normally preferred.

This matters when you have two connections at once, say a cable and Wi-Fi, or a VPN on top of either. A VPN typically adds routes that pull some or all traffic into its tunnel. If you can reach the internet but not the office printer while connected, compare the table before and after the VPN starts. On Linux, ip route get 198.51.100.7 answers the question directly by showing the interface and gateway the system would use for that one address. How routers choose a path explains the same rule at larger scale.

Leases, and renewing them

An address from DHCP is on loan. ipconfig /all on Windows shows when the lease was obtained and when it expires, and also which server issued it. That last detail is a quick way to catch a second device handing out addresses: if the DHCP server isn't your router, find out what it is.

Devices normally renew well before expiry without any action from you. Forcing a renewal makes sense after you've changed router settings, moved to another network segment, or want to pick up a new reservation. If you need a device to keep the same address, a DHCP reservation on the router is usually safer than typing a fixed address into the device, because the router then knows the address is taken.

Decoding the addresses

Address looks like What it usually means
10.x.x.x, 172.16.x.x to 172.31.x.x, 192.168.x.x Private IPv4 on a local network
169.254.x.x Self-assigned link-local address, no DHCP answer
127.0.0.1 or ::1 Loopback, this machine only
100.64.x.x to 100.127.x.x Shared range used by carrier NAT and some VPN tools
fe80:: IPv6 link-local, present on nearly every active interface
fd or fc prefix IPv6 unique local
Starts with 2 or 3 (IPv6) Typically global IPv6

An IPv6-capable interface often holds several addresses at once, including temporary ones that change over time for privacy. That's expected. IPv6 address types sorts them out.

To work out the range covered by a prefix, use the CIDR calculator, or read how subnet masks are calculated.

The address websites see is normally your router's or provider's public address. These commands won't show it on a typical home network. Public and private addresses explains why.

Interface details worth a glance

Each interface also reports a hardware address and often an MTU, the largest packet it will send, commonly 1500 bytes on Ethernet and lower on many tunnels. Phones and many computers can present a randomized MAC address on Wi-Fi, so the value you see may differ from one network to another. That can confuse router access lists and reservations.

On Linux, ip -s link adds counters for received and transmitted packets, errors and drops. Error counts that keep climbing on a wired link suggest a bad cable, connector or port. On Windows, Get-NetAdapterStatistics gives similar totals, and Get-NetAdapter shows each adapter's status and link speed. A wired link that negotiates far below what both ends support is another strong hint of a cabling fault.

Spotting problems

Reading the output when something is wrong
Is the interface down or marked disconnected? YES Check the cable, Wi-Fi switch, or whether the adapter is disabled. 1 NO Is the IPv4 address in the 169.254 range? YES DHCP got no answer. Rejoin the network and check the router. 2 NO Is there an address but no default gateway? YES Local traffic may work, but you cannot reach other networks. 3 NO Are DNS servers missing or unexpected? YES Check network settings, VPN software and the router configuration. 4 NO Configuration looks sane Move on to testing reachability with ping. Is the interface down or marked disconnected? 1 IF YES Check the cable, Wi-Fi switch, or whether the adapter is disabled. NO Is the IPv4 address in the 169.254 range? 2 IF YES DHCP got no answer. Rejoin the network and check the router. NO Is there an address but no default gateway? 3 IF YES Local traffic may work, but you cannot reach other networks. NO Are DNS servers missing or unexpected? 4 IF YES Check network settings, VPN software and the router configuration. NO Configuration looks sane Move on to testing reachability with ping.

Two devices configured with the same address cause intermittent failures that the output on one machine won't always reveal; see IP address conflicts. An address from a subnet you don't recognize may mean you joined a neighbor's or guest network, or that a second router is handing out addresses.

DNS servers you never set deserve a second look. They may come from your provider, a VPN or security software, but unexplained changes can also point to tampering.

A worked example

Say your laptop shows connected to Wi-Fi but no pages load. You run the command for your system and find an address of 192.168.1.34/24, a gateway of 192.168.1.1 and one DNS server, 10.8.0.1. The first two fit a home network. The DNS server doesn't: it's in a different private range.

A likely explanation is that something, perhaps VPN software that didn't shut down cleanly, left its resolver setting behind. You could confirm by looking for a virtual adapter in the full output, then reconnect and disconnect the VPN normally, or reset the adapter's DNS setting to automatic. The point is that a minute of reading narrowed the fault to name resolution before anyone restarted a router.

Now suppose the address had been 169.254.18.7 with no gateway. DNS would be irrelevant. The computer never received a configuration, so you'd look at the router, the DHCP pool and the wireless password or authentication.

Capturing the output

Redirect results to a file when you need to compare or send them:

ipconfig /all > network.txt
ip address > network.txt; ip route >> network.txt

Before posting output publicly, remove MAC addresses, global IPv6 addresses, internal host names and domain suffixes. Together they say a lot about your network.

A useful trick is to save a copy while everything works. When something breaks later, comparing the two files shows at once whether your address, gateway or resolvers changed. With the configuration confirmed, continue to ping to test whether packets get where they should.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Developer & Network Tools →

Latest news on this topic