Networking

Tasks

Get IPs on the machine

ifconfig
networksetup -listallnetworkservices
networksetup -getinfo Ethernet
networksetup -getdnsservers Ethernet
networksetup -getsearchdomains Ethernet

Get routing table

route — manually manipulate the routing tables

route get 192.168.0.1
netstat -nr

ipconfig — view and control IP configuration state

Find out if DHCP is enabled:

ipconfig getpacket en0

Monitor network activity

nettop

Utilities

networksetup — configuration tool for network settings in System Preferences

http://www.manpagez.com/man/8/networksetup/osx-10.11.6.php

user@macosx ~ % networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Ethernet
Wi-Fi
Bluetooth PAN
Thunderbolt Bridge
networksetup -listallhardwareports
networksetup -getinfo Ethernet

Disable WIFI

networksetup -getairportpower en1
networksetup -setairportpower en1 off
networksetup -setnetworkserviceenabled Wi-Fi off

ipconfig — view and control IP configuration state

ipconfig getpacket en0

Refresh IP configuration from DHCP:

ipconfig set en0 DHCP