自用脚本,记录一下。
#!/bin/sh
if [[ $1 == 'c' ]];then
networksetup -setmanual "Wi-Fi" 192.168.10.133 255.255.255.0 192.168.10.254
networksetup -setdnsservers Wi-Fi 192.168.10.254 8.8.4.4
elif [[ $1 == 's' ]];then
networksetup -setmanual "Wi-Fi" 192.168.0.184 255.255.255.0 192.168.0.254
networksetup -setdnsservers Wi-Fi 192.168.0.254 8.8.4.4
elif [[ $1 == 't' ]];then
networksetup -setmanual "Wi-Fi" 192.168.0.184 255.255.255.0 192.168.0.250
networksetup -setdnsservers Wi-Fi 198.18.0.2 8.8.4.4
elif [[ $1 == 'd' ]];then
networksetup -setdhcp "Wi-Fi"
networksetup -setdnsservers Wi-Fi empty
else
echo "[INFO]:please input d|s|t|c to choice dhcp or static."
fi