ipconfig.co.uk

Cross-platform network command cheat sheet

The same tasks, five ways. Rows are grouped by what you are trying to do. Print it, or bookmark it. Commands that change settings need an administrator prompt or sudo.

See your configuration

TaskWindows CMDPowerShellLinux (ip)macOS
Quick summaryipconfigGet-NetIPConfigurationip -br addrifconfig -u or networksetup -getinfo "Wi-Fi"
Full detailipconfig /allGet-NetIPConfiguration -Detailedip addrifconfig -a
One interfaceipconfig (then read)Get-NetIPConfiguration -InterfaceAlias Ethernetip addr show dev eth0ifconfig en0
Just the IPv4 addressipconfig | findstr IPv4(Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias Ethernet).IPAddresshostname -I or ip -4 -o addr show eth0 | awk '{print $4}'ipconfig getifaddr en0
IPv6 addressesipconfigGet-NetIPAddress -AddressFamily IPv6ip -6 addrifconfig en0 inet6
MAC addressipconfig /all or getmac /vGet-NetAdapter | select Name, MacAddressip link or cat /sys/class/net/eth0/addressifconfig en0 ether or networksetup -getmacaddress en0
Default gatewayipconfig or route print 0.0.0.0Get-NetRoute -DestinationPrefix 0.0.0.0/0ip route | grep defaultroute -n get default
DNS serversipconfig /allGet-DnsClientServerAddressresolvectl status or cat /etc/resolv.confscutil --dns
DHCP server and leaseipconfig /allGet-NetIPAddress | select PrefixOrigin, ValidLifetimeip addr (valid_lft) or networkctl status eth0ipconfig getpacket en0
Link speed / duplexwmic nic get name,speedGet-NetAdapter | select Name, LinkSpeedethtool eth0ifconfig en0 | grep media
Interface listnetsh interface show interfaceGet-NetAdapterip -br linkifconfig -l or networksetup -listallhardwareports
Traffic countersnetstat -eGet-NetAdapterStatisticsip -s linknetstat -ib
Wi-Fi SSID and signalnetsh wlan show interfaces(same)iw dev wlan0 link or nmcli dev wifisudo wdutil info
Public IPcurl ipconfig.co.uk/ipirm ipconfig.co.uk/ipcurl ipconfig.co.uk/ipcurl ipconfig.co.uk/ip

Routing and neighbours

TaskWindows CMDPowerShellLinux (ip)macOS
Routing tableroute printGet-NetRouteip routenetstat -rn
IPv6 routesroute print -6Get-NetRoute -AddressFamily IPv6ip -6 routenetstat -rn -f inet6
Which route to X(none)Find-NetRoute -RemoteIPAddress 1.1.1.1ip route get 1.1.1.1route -n get 1.1.1.1
Add a routeroute add 10.0.0.0 mask 255.0.0.0 192.168.1.254New-NetRoute -DestinationPrefix 10.0.0.0/8 -NextHop 192.168.1.254 -InterfaceAlias Ethernetip route add 10.0.0.0/8 via 192.168.1.254route add -net 10.0.0.0/8 192.168.1.254
Persistent routeroute -p add …New-NetRoute (persistent by default)via nmcli / networkd / netplan(use a LaunchDaemon or networksetup -setadditionalroutes on 14+)
Delete a routeroute delete 10.0.0.0Remove-NetRoute -DestinationPrefix 10.0.0.0/8ip route del 10.0.0.0/8route delete -net 10.0.0.0/8
Set default gatewayroute add 0.0.0.0 mask 0.0.0.0 192.168.1.1New-NetRoute -DestinationPrefix 0.0.0.0/0 -NextHop 192.168.1.1 -InterfaceAlias Ethernetip route add default via 192.168.1.1route add default 192.168.1.1
ARP / neighbour tablearp -aGet-NetNeighborip neigharp -an
IPv6 neighboursnetsh interface ipv6 show neighborsGet-NetNeighbor -AddressFamily IPv6ip -6 neighndp -an
Clear ARP cachearp -d *Remove-NetNeighbor -Confirm:$falseip neigh flush allsudo arp -d -a
Static ARP entryarp -s 192.168.1.5 00-11-22-33-44-55New-NetNeighbor -IPAddress 192.168.1.5 -LinkLayerAddress 001122334455 -InterfaceAlias Ethernetip neigh add 192.168.1.5 lladdr 00:11:22:33:44:55 dev eth0 nud permanentsudo arp -s 192.168.1.5 00:11:22:33:44:55

DHCP and DNS cache

TaskWindows CMDPowerShellLinuxmacOS
Release DHCP leaseipconfig /releaseipconfig /releasedhclient -r eth0 or nmcli con down "X"sudo ipconfig set en0 NONE
Renew DHCP leaseipconfig /renewipconfig /renewdhclient eth0, nmcli con up "X", networkctl renew eth0sudo ipconfig set en0 DHCP
Renew IPv6 (DHCPv6)ipconfig /renew6(same)depends on clientsudo ipconfig set en0 AUTOMATIC-V6
Flush DNS cacheipconfig /flushdnsClear-DnsClientCacheresolvectl flush-cachessudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Show DNS cacheipconfig /displaydnsGet-DnsClientCacheresolvectl statistics (counts only)(not exposed)
Re-register in DNSipconfig /registerdnsRegister-DnsClientnsupdate / DHCP client does it(mDNS automatic)
Look up a namenslookup example.comResolve-DnsName example.comdig example.com or resolvectl query example.comdig example.com or dscacheutil -q host -a name example.com
Look up with a specific servernslookup example.com 1.1.1.1Resolve-DnsName example.com -Server 1.1.1.1dig @1.1.1.1 example.comdig @1.1.1.1 example.com
Reverse lookupnslookup 1.1.1.1Resolve-DnsName 1.1.1.1dig -x 1.1.1.1dig -x 1.1.1.1
Hosts fileC:\Windows\System32\drivers\etc\hosts(same)/etc/hosts/etc/hosts

Change settings

TaskWindows CMD (netsh)PowerShellLinuxmacOS
Static IPv4 (temporary)(persistent only)(persistent only)ip addr add 192.168.1.50/24 dev eth0sudo ifconfig en0 inet 192.168.1.50 netmask 255.255.255.0
Static IPv4 (persistent)netsh interface ipv4 set address "Ethernet" static 192.168.1.50 255.255.255.0 192.168.1.1New-NetIPAddress -InterfaceAlias Ethernet -IPAddress 192.168.1.50 -PrefixLength 24 -DefaultGateway 192.168.1.1nmcli con mod "X" ipv4.method manual ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1sudo networksetup -setmanual "Wi-Fi" 192.168.1.50 255.255.255.0 192.168.1.1
Back to DHCPnetsh interface ipv4 set address "Ethernet" dhcpSet-NetIPInterface -InterfaceAlias Ethernet -Dhcp Enablednmcli con mod "X" ipv4.method autosudo networksetup -setdhcp "Wi-Fi"
Set DNS serversnetsh interface ipv4 set dnsservers "Ethernet" static 1.1.1.1Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses 1.1.1.1,1.0.0.1nmcli con mod "X" ipv4.dns "1.1.1.1 1.0.0.1" or resolvectl dns eth0 1.1.1.1sudo networksetup -setdnsservers "Wi-Fi" 1.1.1.1 1.0.0.1
DNS from DHCP againnetsh interface ipv4 set dnsservers "Ethernet" dhcpSet-DnsClientServerAddress -InterfaceAlias Ethernet -ResetServerAddressesnmcli con mod "X" ipv4.dns ""sudo networksetup -setdnsservers "Wi-Fi" Empty
Interface down / upnetsh interface set interface "Wi-Fi" admin=disableDisable-NetAdapter -Name Wi-Fi / Enable-NetAdapterip link set eth0 down / upsudo ifconfig en0 down / up
Restart interface(disable then enable)Restart-NetAdapter -Name Ethernetnmcli dev reapply eth0sudo ifconfig en0 down; sudo ifconfig en0 up
Set MTUnetsh interface ipv4 set subinterface "Ethernet" mtu=1400 store=persistentSet-NetIPInterface -InterfaceAlias Ethernet -NlMtuBytes 1400ip link set eth0 mtu 1400sudo networksetup -setMTU en0 1400
Change MAC(driver property in Device Manager)Set-NetAdapter -Name Ethernet -MacAddress 02-11-22-33-44-55ip link set eth0 address 02:11:22:33:44:55sudo ifconfig en0 ether 02:11:22:33:44:55
Disable IPv6 on an adapternetsh interface ipv6 set interface "Ethernet" … (partial)Disable-NetAdapterBinding -Name Ethernet -ComponentID ms_tcpip6nmcli con mod "X" ipv6.method disabledsudo networksetup -setv6off "Wi-Fi"
Reset the stacknetsh int ip reset & netsh winsock reset(same)systemctl restart NetworkManagersee macOS reset

Connectivity tests

TaskWindows CMDPowerShellLinuxmacOS
Pingping host (4 packets)Test-Connection hostping -c 4 hostping -c 4 host
Continuous pingping -t hostTest-Connection host -Repeat (PS 7)ping hostping host
Ping IPv6ping -6 hostTest-Connection -IPv6 hostping -6 hostping6 host
Trace routetracert hostTest-NetConnection host -TraceRoutetraceroute host / mtr hosttraceroute host
Test a TCP porttelnet host 443Test-NetConnection host -Port 443nc -zv host 443nc -zv host 443
MTU test (1500)ping -f -l 1472 host(same)ping -M do -s 1472 hostping -D -s 1472 host
Listening portsnetstat -ano | findstr LISTENINGGet-NetTCPConnection -State Listenss -tulpnlsof -iTCP -sTCP:LISTEN -P -n
Established connectionsnetstat -anoGet-NetTCPConnection -State Establishedss -tan state establishednetstat -an | grep ESTABLISHED
Packet capturepktmon start --capture(same)tcpdump -i eth0tcpdump -i en0
Scan the LAN(none built in)1..254 | % { Test-Connection -Count 1 -Quiet "192.168.1.$_" }nmap -sn 192.168.1.0/24nmap -sn 192.168.1.0/24 (Homebrew)

Terminology map

ConceptWindows saysLinux saysmacOS/BSD says
Network interfaceadapter, connection ("Ethernet", "Wi-Fi")interface, device, link (eth0, enp3s0)interface, port, service ("en0", "Wi-Fi")
MAC addressPhysical Address, 8C-16-45-3A-9B-2Dlink/ether, HWaddr, 8c:16:45:3a:9b:2dether, Ethernet Address, 8c:16:45:3a:9b:2d
Subnet maskSubnet Mask 255.255.255.0prefix length /24 (ifconfig: netmask 255.255.255.0)netmask 0xffffff00
Default gatewayDefault Gatewaydefault viagateway / Router
Link-local IPv6 zone%12 (interface index)%eth0 (name) or index%en0
No linkMedia disconnectedNO-CARRIER, state DOWNstatus: inactive
Self-assigned addressAutoconfiguration IPv4 Address (APIPA)link-local 169.254 (avahi-autoipd / IPv4LL)self-assigned IP
DNS cache serviceDNS Client (Dnscache)systemd-resolved / nscd / dnsmasqmDNSResponder
Persistent configRegistry, via netsh/PowerShell/SettingsNetworkManager, networkd, netplan, ifupdownSystem Configuration (configd) via networksetup

Related pages

Last reviewed . Command syntax verified against Windows 11, Ubuntu 24.04, macOS 15 and FreeBSD 14 unless noted otherwise.

Spotted a mistake or a switch we have missed? Every page on this site is written to be checked against real output, so please test on your own machine and compare.