Same Job, Different Shell Part 3: Interface and IP Configuration

“What’s my IP” is the most basic networking question there is, and it’s the one where the two platforms have drifted furthest apart in how they answer it. Linux went through a full tool replacement (ifconfig to ip) that Windows never needed to make, because PowerShell’s networking cmdlets arrived already split cleanly by concern: one cmdlet for addresses, a separate one for the adapter itself.

Linux: ip addr, and why ifconfig is legacy

ifconfig still works on most distros if net-tools is installed, but it hasn’t been updated to understand VRFs, network namespaces, or policy routing, and it’s frequently just absent from a minimal install (it was on this sandbox: not installed by default, apt install net-tools was required to get it). ip, from iproute2, is the current tool and understands all of that.

$ ip -brief addr show
lo               UNKNOWN        127.0.0.1/8
eth0             UP             192.0.2.2/24

-brief gives you the one-line-per-interface summary. Drop it for the full detail, including MAC address, MTU, and interface flags:

$ ip addr show eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:fc:00:00:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.2/24 brd 192.0.2.255 scope global eth0
       valid_lft forever preferred_lft forever

For interface state and hardware detail without the IP addressing noise, ip link is the narrower view:

$ ip -brief link show
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0             UP             02:fc:00:00:00:01 <BROADCAST,MULTICAST,UP,LOWER_UP>

The legacy equivalent, if you’re on a box old enough or minimal enough that ifconfig is what’s there:

$ ifconfig eth0

produces roughly the same information in an older, less structured text format, and won’t show you anything ip can’t.

Windows: ipconfig for a quick look, cmdlets for anything scriptable

ipconfig is the ifconfig-era tool here: fast, always present, fine for a human glancing at a screen, awkward for anything you want to parse or filter.

C:\> ipconfig /all

gives you the full per-adapter dump: IPv4/IPv6 address, subnet mask, default gateway, DNS servers, DHCP lease times, all of it, in fixed text.

For anything you’re going to filter, pipe, or use inside a script, the NetTCPIP and NetAdapter PowerShell modules split the same information into two purpose-built cmdlets instead of one big dump. Here’s real output from an ordinary desktop, which is a much more honest picture than a two-adapter demo:

PS> Get-NetIPAddress -AddressFamily IPv4 |
    Format-Table IPAddress, InterfaceAlias, PrefixLength, AddressFamily

IPAddress       InterfaceAlias                     PrefixLength AddressFamily
---------       --------------                     ------------ -------------
172.28.80.1     vEthernet (WSL (Hyper-V firewall))           20          IPv4
169.254.230.89  WiFi 3                                       16          IPv4
169.254.209.18  Bluetooth Network Connection                 16          IPv4
169.254.250.114 WiFi 2                                       16          IPv4
192.168.1.50    WiFi                                         24          IPv4
169.254.139.222 VPN Client WinTUN Adapter                    16          IPv4
127.0.0.1       Loopback Pseudo-Interface 1                   8          IPv4

A real box has real clutter, and this is worth reading properly rather than skipping past. The 169.254.x.x addresses on WiFi 2, WiFi 3, Bluetooth Network Connection, and the VPN adapter are APIPA, Windows’ automatic fallback address for an adapter that exists but never got a real DHCP lease, because nothing’s actually plugged into it or associated with it right now. Seeing several 169.254.x.x entries in this output doesn’t mean several broken connections, it means several adapters that are present but not currently doing anything. Only WiFi (192.168.1.50, a real DHCP-assigned address) and the WSL virtual switch (172.28.80.1, Hyper-V’s own internal network for the Windows Subsystem for Linux) are actually carrying traffic here.

# the adapter itself: link state, MAC, speed, nothing about IP addressing
PS> Get-NetAdapter | Format-Table Name, InterfaceDescription, Status, MacAddress, LinkSpeed

Name                               InterfaceDescription                      Status       MacAddress        LinkSpeed
----                               --------------------                      ------       ----------        ---------
vEthernet (WSL (Hyper-V firewall)) Hyper-V Virtual Ethernet Adapter          Up           02:00:00:00:00:01 10 Gbps
VPN Client WinTUN Adapter          VPN Tunnel                                Disconnected                   100 Gbps
Bluetooth Network Connection       Bluetooth Device (Personal Area Network)  Disconnected 02:00:00:00:00:02 3 Mbps
WiFi 5                             MediaTek Wi-Fi 7 MT7925 Wireless LAN Card Not Present                    0 bps
WiFi 4                             MediaTek Wi-Fi 7 MT7925 Wireless LAN Card Not Present                    0 bps
WiFi                               MediaTek Wi-Fi 7 MT7925 Wireless LAN Card Up           02:00:00:00:00:03 702 Mbps
Ethernet 3                         SSL VPN Virtual Ethernet Adapter          Not Present  02:00:00:00:00:04 0 bps

Two more things this real output catches that a clean demo wouldn’t. LinkSpeed on the disconnected VPN adapter reads 100 Gbps, which is not a real measured speed, it’s a static capability value the virtual driver reports regardless of whether anything is actually connected. Trust LinkSpeed on an adapter whose Status is Up; ignore it everywhere else. And the five separate WiFi/WiFi 2/WiFi 3/WiFi 4/WiFi 5 entries aren’t five physical cards, they’re Windows’ virtual WiFi miniport adapters (used for mobile hotspot and Wi-Fi Direct) riding on one real radio, most of them dormant (Not Present) until something actually activates that feature. If Get-NetAdapter on a laptop shows more Wi-Fi entries than the machine has physical radios, this is why.

PS> Get-NetIPAddress -AddressFamily IPv4

IPAddress         : 192.168.1.50
InterfaceAlias    : WiFi
PrefixLength      : 24
AddressFamily     : IPv4

That’s the same data as the table above, one record at a time, useful when you’re piping a single result into something else rather than reading it yourself.

That split, one cmdlet for addresses and a separate one for the adapter, is the real structural difference from Linux’s ip. ip addr and ip link are two subcommands of one tool that both operate on the same object (the interface); Get-NetIPAddress and Get-NetAdapter are two entirely separate cmdlets returning two entirely separate object types, joined only by InterfaceAlias/InterfaceIndex. If you want the Windows equivalent of ip addr show eth0 (interface state and its addresses in one view), the closest built-in is:

PS> Get-NetIPConfiguration -InterfaceAlias "WiFi"

which pulls address, gateway, and DNS server together per interface, closer in spirit to ipconfig /all than to either Get-NetIPAddress or Get-NetAdapter alone.

Setting an address, not just reading it

Reading is the common case, but it’s worth knowing the write side exists on both platforms, since “what’s my IP” often comes right before “change my IP.”

# Linux: assign, and separately, set default route
sudo ip addr add 192.0.2.50/24 dev eth0
sudo ip route add default via 192.0.2.1
# Windows: one cmdlet, address and gateway together
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.0.2.50 -PrefixLength 24 -DefaultGateway 192.0.2.1

Neither of these persists across a reboot on its own unless the underlying config (netplan/NetworkManager on Linux, the adapter’s saved profile on Windows) is also updated. Both are fine for “I need this right now to test something.”

Quick reference

What you wantLinuxWindows
Quick one-line-per-interface summaryip -brief addr showipconfig
Full detail, all adaptersip addr showipconfig /all
Just this interfaceip addr show eth0Get-NetIPConfiguration -InterfaceAlias "WiFi"
IPv4 addresses onlyip -4 addr showGet-NetIPAddress -AddressFamily IPv4
Adapter/link state, no IP noiseip -brief link showGet-NetAdapter
Legacy tool (usually still present)ifconfigipconfig
Assign an addressip addr add <cidr> dev <if>New-NetIPAddress -InterfaceAlias <if> -IPAddress <ip> -PrefixLength <n>

What’s next

Part 4 covers the routing table itself: ip route and route -n against route print and Get-NetRoute, once you know your own address the next question is always where traffic actually goes from here.

Cross-references: for the full model behind ip (VRFs, policy routing, namespaces, JSON output) see Beyond ifconfig: The ip Command Reference Every Network Engineer Needs.