ipconfig
ipconfig getoption en0 subnet_mask
ipconfig getoption en0 domain_name_server
- get
info about how en0 got its dhcp on
ipconfig set en0 DHCP
# or this
ipconfig set en1 BOOTP && ipconfig set en1 DHCP
ifconfig en1 down && ifconfig en1 up
- set a specific ip address
ipconfig set en0 INFORM 192.168.1.160
ifconfig
- set
ip address
and netmask
ifconfig en0 inet 192.168.1.154 netmask 255.255.255.0
ipconfig set en0 BOOTP && ipconfig set en0 DHCP
ifconfig en0 down && ifconfig en0 up
networksetup
- get a list of
location
on the computer
networksetup -listlocations
networksetup -getcurrentlocation
- config manual
static ip address
networksetup -setmanual Wi-Fi 192.168.1.154 255.255.255.0 192.168.1.253
networksetup -setdnsservers Wi-Fi 192.168.1.154 192.168.1.253
networksetup -getdnsservers Wi-Fi
firewall
- stop the application layer firewall
launchctl unload /System/Library/LaunchAgents/com.apple.alf.useragent.plist
launchctl unload /System/Library/LaunchAgents/com.apple.alf.agent.plist
- start the application layer firewall
launchctl load /System/Library/LaunchAgents/com.apple.alf.agent.plist
launchctl load /System/Library/LaunchAgents/com.apple.alf.useragent.plist
- allow an app to communicate outside through the application layer firewall
socketfilterfw -t "/Applications/..."
route
# so that traffice for 192.168.1.0/24
# communicates over the 192.168.1.253
sudo route -n add 192.168.1.0/24 192.168.1.253
sudo route -n delete 192.168.1.0/24 192.168.1.253
netstat
- per protocol network statistics
- statistics for a specific network protocol
- statistics for network interfaces
- view network info as it happens
ping
- ping hostname 5 times and then stop
- set packet size during ping
ping -s 100 192.168.1.253
- customize source ip during ping
ping -S 192.168.1.160 192.168.1.253
trace
- trace the path packets go through
nc
- establish a network connection
- establish a network connection over port 2195
nc -v -w 15 baidu.com 2196
- establish a network connection only allowing ipv4
- setup a network listener on port 2196 for testing
tcpdump
- capture all packets for a given port going to destination 192.168.1.160
tcpdump -nnvvXs 548 dst 192.168.1.160
- capture packets as above but dump to a pcap file
tcpdump -nnvvXs 548 dst 192.168.1.160 -w /tmp/demo.pcap
- read tcpdump (cap) files and make them human readable
tcpdump -qns 0 -A -r /tmp/demo.pcap
other
- what binaries have what ports and in what states are those ports
- make an alias for looking at what has a listener open, called ports
alias ports='lsof -n -i4TCP | grep LISTEN'
sudo vim /private/etc/hosts