Mac Network Commands Cheat Sheet
Mac Network Commands Cheat Sheet
ipconfig
1. get ip address
ifconfig
1. get network info
$ ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 34:36:3b:cd:fd:ae
inet6 fe80::3636:3bff:fecd:fdae%en0 prefixlen 64 scopeid 0x4
inet 192.168.1.154 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=1<PERFORMNUD>
media: autoselect
status: active
networksetup
1. get a list of location on the computer
$ networksetup -listlocations
Automatic
$ networksetup -getcurrentlocation
Automatic
firewall
1. stop the application layer firewall
$ socketfilterfw -t "/Applications/..."
route
1. routing table
$ netstat -nr
2. add a route
3. delete a route
netstat
1. view info on all sockets
$ netstat -at
$ netstat -lt
$ netstat -s
$ netstat -p igmp
$ netstat -i
$ ntop
ping
1. put a delay in pings
$ ping -i 5 192.168.1.253
$ ping -c 5 192.168.1.253
$ ping -f location
trace
1. trace the path packets go through
$ traceroute baidu.com
$ traceroute -n baidu.com
3. in debug mode
$ traceroute -d baidu.com
nc
1. establish a network connection
$ nc -v baidu.com 80
$ nc -v -w 15 baidu.com 2196
$ nc -v -4 baidu.com 2196
$ nc -l 2196
tcpdump
1. capture some packets
$ tcpdump -nS
$ tcpdump-nnvvXS
other
1. flush the dns cache
$ dscacheutil -flushcache
$ arp -ad
3. what binaries have what ports and in what states are those ports
$ lsof -n -i4TCP
4. make an alias for looking at what has a listener open, called ports
references
1. mac network commands cheat sheet
mac 5
network 5