Home › Cross-platform network command cheat sheet
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
Task Windows CMD PowerShell Linux (ip) macOS Quick summary ipconfigGet-NetIPConfigurationip -br addrifconfig -u or networksetup -getinfo "Wi-Fi"Full detail ipconfig /allGet-NetIPConfiguration -Detailedip addrifconfig -aOne interface ipconfig (then read)Get-NetIPConfiguration -InterfaceAlias Ethernetip addr show dev eth0ifconfig en0Just the IPv4 address ipconfig | findstr IPv4(Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias Ethernet).IPAddresshostname -I or ip -4 -o addr show eth0 | awk '{print $4}'ipconfig getifaddr en0IPv6 addresses ipconfigGet-NetIPAddress -AddressFamily IPv6ip -6 addrifconfig en0 inet6MAC address ipconfig /all or getmac /vGet-NetAdapter | select Name, MacAddressip link or cat /sys/class/net/eth0/addressifconfig en0 ether or networksetup -getmacaddress en0Default gateway ipconfig or route print 0.0.0.0Get-NetRoute -DestinationPrefix 0.0.0.0/0ip route | grep defaultroute -n get defaultDNS servers ipconfig /allGet-DnsClientServerAddressresolvectl status or cat /etc/resolv.confscutil --dnsDHCP server and lease ipconfig /allGet-NetIPAddress | select PrefixOrigin, ValidLifetimeip addr (valid_lft) or networkctl status eth0ipconfig getpacket en0Link speed / duplex wmic nic get name,speedGet-NetAdapter | select Name, LinkSpeedethtool eth0ifconfig en0 | grep mediaInterface list netsh interface show interfaceGet-NetAdapterip -br linkifconfig -l or networksetup -listallhardwareportsTraffic counters netstat -eGet-NetAdapterStatisticsip -s linknetstat -ibWi-Fi SSID and signal netsh wlan show interfaces(same) iw dev wlan0 link or nmcli dev wifisudo wdutil infoPublic IP curl ipconfig.co.uk/ipirm ipconfig.co.uk/ipcurl ipconfig.co.uk/ipcurl ipconfig.co.uk/ip
Routing and neighbours
Task Windows CMD PowerShell Linux (ip) macOS Routing table route printGet-NetRouteip routenetstat -rnIPv6 routes route print -6Get-NetRoute -AddressFamily IPv6ip -6 routenetstat -rn -f inet6Which route to X (none) Find-NetRoute -RemoteIPAddress 1.1.1.1ip route get 1.1.1.1route -n get 1.1.1.1Add a route route 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.254Persistent route route -p add …New-NetRoute (persistent by default)via nmcli / networkd / netplan (use a LaunchDaemon or networksetup -setadditionalroutes on 14+) Delete a route route 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/8Set default gateway route 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.1ARP / neighbour table arp -aGet-NetNeighborip neigharp -anIPv6 neighbours netsh interface ipv6 show neighborsGet-NetNeighbor -AddressFamily IPv6ip -6 neighndp -anClear ARP cache arp -d *Remove-NetNeighbor -Confirm:$falseip neigh flush allsudo arp -d -aStatic ARP entry arp -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
Task Windows CMD PowerShell Linux macOS Release DHCP lease ipconfig /releaseipconfig /releasedhclient -r eth0 or nmcli con down "X"sudo ipconfig set en0 NONERenew DHCP lease ipconfig /renewipconfig /renewdhclient eth0, nmcli con up "X", networkctl renew eth0sudo ipconfig set en0 DHCPRenew IPv6 (DHCPv6) ipconfig /renew6(same) depends on client sudo ipconfig set en0 AUTOMATIC-V6Flush DNS cache ipconfig /flushdnsClear-DnsClientCacheresolvectl flush-cachessudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderShow DNS cache ipconfig /displaydnsGet-DnsClientCacheresolvectl statistics (counts only)(not exposed) Re-register in DNS ipconfig /registerdnsRegister-DnsClientnsupdate / DHCP client does it(mDNS automatic) Look up a name nslookup example.comResolve-DnsName example.comdig example.com or resolvectl query example.comdig example.com or dscacheutil -q host -a name example.comLook up with a specific server nslookup 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.comReverse lookup nslookup 1.1.1.1Resolve-DnsName 1.1.1.1dig -x 1.1.1.1dig -x 1.1.1.1Hosts file C:\Windows\System32\drivers\etc\hosts(same) /etc/hosts/etc/hosts
Change settings
Task Windows CMD (netsh) PowerShell Linux macOS 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.0Static 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.1Back to DHCP netsh interface ipv4 set address "Ethernet" dhcpSet-NetIPInterface -InterfaceAlias Ethernet -Dhcp Enablednmcli con mod "X" ipv4.method autosudo networksetup -setdhcp "Wi-Fi"Set DNS servers netsh 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.1DNS from DHCP again netsh interface ipv4 set dnsservers "Ethernet" dhcpSet-DnsClientServerAddress -InterfaceAlias Ethernet -ResetServerAddressesnmcli con mod "X" ipv4.dns ""sudo networksetup -setdnsservers "Wi-Fi" EmptyInterface down / up netsh interface set interface "Wi-Fi" admin=disableDisable-NetAdapter -Name Wi-Fi / Enable-NetAdapterip link set eth0 down / upsudo ifconfig en0 down / upRestart interface (disable then enable) Restart-NetAdapter -Name Ethernetnmcli dev reapply eth0sudo ifconfig en0 down; sudo ifconfig en0 upSet MTU netsh interface ipv4 set subinterface "Ethernet" mtu=1400 store=persistentSet-NetIPInterface -InterfaceAlias Ethernet -NlMtuBytes 1400ip link set eth0 mtu 1400sudo networksetup -setMTU en0 1400Change 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:55Disable IPv6 on an adapter netsh 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 stack netsh int ip reset & netsh winsock reset(same) systemctl restart NetworkManagersee macOS reset
Connectivity tests
Task Windows CMD PowerShell Linux macOS Ping ping host (4 packets)Test-Connection hostping -c 4 hostping -c 4 hostContinuous ping ping -t hostTest-Connection host -Repeat (PS 7)ping hostping hostPing IPv6 ping -6 hostTest-Connection -IPv6 hostping -6 hostping6 hostTrace route tracert hostTest-NetConnection host -TraceRoutetraceroute host / mtr hosttraceroute hostTest a TCP port telnet host 443Test-NetConnection host -Port 443nc -zv host 443nc -zv host 443MTU test (1500) ping -f -l 1472 host(same) ping -M do -s 1472 hostping -D -s 1472 hostListening ports netstat -ano | findstr LISTENINGGet-NetTCPConnection -State Listenss -tulpnlsof -iTCP -sTCP:LISTEN -P -nEstablished connections netstat -anoGet-NetTCPConnection -State Establishedss -tan state establishednetstat -an | grep ESTABLISHEDPacket capture pktmon start --capture(same) tcpdump -i eth0tcpdump -i en0Scan 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
Concept Windows says Linux says macOS/BSD says Network interface adapter, connection ("Ethernet", "Wi-Fi") interface, device, link (eth0, enp3s0) interface, port, service ("en0", "Wi-Fi") MAC address Physical Address, 8C-16-45-3A-9B-2D link/ether, HWaddr, 8c:16:45:3a:9b:2d ether, Ethernet Address, 8c:16:45:3a:9b:2d Subnet mask Subnet Mask 255.255.255.0 prefix length /24 (ifconfig: netmask 255.255.255.0) netmask 0xffffff00 Default gateway Default Gateway default via gateway / Router Link-local IPv6 zone %12 (interface index)%eth0 (name) or index%en0No link Media disconnected NO-CARRIER, state DOWN status: inactive Self-assigned address Autoconfiguration IPv4 Address (APIPA) link-local 169.254 (avahi-autoipd / IPv4LL) self-assigned IP DNS cache service DNS Client (Dnscache) systemd-resolved / nscd / dnsmasq mDNSResponder Persistent config Registry, via netsh/PowerShell/Settings NetworkManager, networkd, netplan, ifupdown System Configuration (configd) via networksetup
Related pages