Skip to content

Instantly share code, notes, and snippets.

@millievn
Forked from jjnilton/mac-network-commands-cheat-sheet.md
Last active October 27, 2021 05:33
Show Gist options
  • Save millievn/3c484973567aa0ea7cbc19d93abd94cc to your computer and use it in GitHub Desktop.
Save millievn/3c484973567aa0ea7cbc19d93abd94cc to your computer and use it in GitHub Desktop.
Mac Commands

ipconfig

Get an ip address for en0:

ipconfig getifaddr en0

Same thing, but setting and echoing a variable:

View the subnet mask of en0:

ipconfig getoption en0 subnet_mask

View the dns server for en0:

ipconfig getoption en0 domain_name_server

Get information about how en0 got its DHCP on:

ipconfig getpacket en1

View some network info:

ifconfig en0

Set en0 to have an IP address of 10.10.10.10 and a subnet mask of 255.255.255.0:

ifconfig en0 inet 10.10.10.10 netmask 255.255.255.0

ping

Put a delay in your pings:

ping -i 5 192.168.210.1

Ping the hostname 5 times and then stop the ping:

ping -c 5 google.com

Flood ping the host:

ping -f localhost

Set the packet size during your ping:

ping -s 100 google.com

Customize the source IP during your ping:

ping -S 10.10.10.11 google.com

View disk performance:

iostat -d disk0

traceroute

Trace the path packets go through:

traceroute google.com

Trace the routes without looking up names:

traceroute -n google.com

Trace a route in debug mode:

traceroute -d google.com

dns

Flush the dns cache:

dscacheutil -flushcache

Clear your arp cache:

arp -ad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment