mac 持久化配置 ip

62 阅读1分钟

mac 默认只有 ifconfig, 但是 ifconfig 的配置是临时的,可以使用 networksetup 持久化配置



➜  ~ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
AX88179A
Thunderbolt Bridge
Wi-Fi
➜  ~ networksetup -getinfo AX88179A
DHCP Configuration
IP address: 169.254.16.98
Subnet mask: 255.255.0.0
Router: (null)
Client ID:
IPv6: Automatic
IPv6 IP address: none
IPv6 Router: none
Ethernet Address: 08:26:ae:3f:9f:25
➜  ~ ifconfig | grep  -C 4  08:26:ae:3f:9f:25
	inet6 fe80::8a84:1fdd:9a86:4120%utun6 prefixlen 64 scopeid 0x19
	nd6 options=201<PERFORMNUD,DAD>
en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=404<VLAN_MTU,CHANNEL_IO>
	ether 08:26:ae:3f:9f:25
	inet6 fe80::147f:93f2:32e4:579d%en7 prefixlen 64 secured scopeid 0xd
	inet 169.254.16.98 netmask 0xffff0000 broadcast 169.254.255.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (1000baseT <full-duplex>)
➜  ~ networksetup -setmanual AX88179A 192.168.71.25 255.255.255.0
➜  ~


➜  ~ networksetup -setmanual AX88179A 192.168.100.xx 255.255.255.0
➜  ~
➜  ~
➜  ~ ifconfig | grep -C 5 AX88179A
➜  ~
➜  ~
➜  ~ ifconfig | grep -C 5 192.168.100.101
	nd6 options=201<PERFORMNUD,DAD>
en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=404<VLAN_MTU,CHANNEL_IO>
	ether 08:26:ae:3f:9f:25
	inet6 fe80::147f:93f2:32e4:579d%en7 prefixlen 64 secured scopeid 0xd
	inet 192.168.100.101 netmask 0xffffff00 broadcast 192.168.100.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (1000baseT <full-duplex>)
	status: active