Mac OS 修改ip
使用VNC远程修改IP v4会:报无效的服务器地址 BasicIPv6ValidationError
所以还是用命令吧!设置IPv4地址
终端输入:networksetup -setmanual Ethernet 192.168.31.2 255.255.255.0 192.168.1.1
对应网卡设备、IP地址、子网掩码、网关
为什么是“Ethernet” 看下面
先ifconfig
查看网卡文件,如下好多网卡文件,这样问题来了、要修改那个???
ptr:~ roothost$ ifconfig lo0: flags=8049 mtu 16384 options=1203 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=201 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 XHC1: flags=0<> mtu 0 VHC128: flags=0<> mtu 0 XHC0: flags=0<> mtu 0 XHC20: flags=0<> mtu 0 en0: flags=8863 mtu 1500 options=167 ether f0:18:98:ee:ce:27 inet6 fe80::14d1:b079:33a:2898%en0 prefixlen 64 secured scopeid 0x8 nd6 options=201 media: autoselect (1000baseT ) status: active en6: flags=8863 mtu 1500 ether ac:de:48:00:11:22 inet6 fe80::aede:48ff:fe00:1122%en6 prefixlen 64 scopeid 0x9 nd6 options=201 media: autoselect (100baseTX ) status: active ap1: flags=8802 mtu 1500 ether 3a:f9:d3:1a:44:29 media: autoselect status: inactive en1: flags=8863 mtu 1500 ether 38:f9:d3:1a:44:29 inet6 fe80::9f:9495:7cdc:eae5%en1 prefixlen 64 secured scopeid 0xb nd6 options=201 media: autoselect () p2p0: flags=8802 mtu 2304 ether 0a:f9:d3:1a:44:29 media: autoselect status: inactive awdl0: flags=8902 mtu 1484 ether 1e:4a:71:da:81:7c nd6 options=201 media: autoselect status: inactive en2: flags=8963 mtu 1500 options=60 ether c6:00:0d:31:0c:01 media: autoselect status: inactive en3: flags=8963 mtu 1500 options=60 ether c6:00:0d:31:0c:00 media: autoselect status: inactive en4: flags=8963 mtu 1500 options=60 ether c6:00:0d:31:0c:05 media: autoselect status: inactive en5: flags=8963 mtu 1500 options=60 ether c6:00:0d:31:0c:04 media: autoselect status: inactive bridge0: flags=8863 mtu 1500 options=63 ether c6:00:0d:31:0c:01 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x2 member: en2 flags=3 ifmaxaddr 0 port 14 priority 0 path cost 0 member: en3 flags=3 ifmaxaddr 0 port 15 priority 0 path cost 0 member: en4 flags=3 ifmaxaddr 0 port 16 priority 0 path cost 0 member: en5 flags=3 ifmaxaddr 0 port 17 priority 0 path cost 0 nd6 options=201 media: status: inactive utun0: flags=8051 mtu 2000 inet6 fe80::305f:45b7:1f5:76f1%utun0 prefixlen 64 scopeid 0x13 nd6 options=201 ptr:~ roothost$
我们可以使用:networksetup -listallhardwareports
网卡设备使用的网卡文件
ptr:~ roothost$ networksetup -listallhardwareports Hardware Port: Ethernet Device: en0 Ethernet Address: f0:18:98:ee:ce:27 Hardware Port: Wi-Fi Device: en1 Ethernet Address: 38:f9:d3:1a:44:29 Hardware Port: Bluetooth PAN Device: en7 Ethernet Address: 38:f9:d3:bf:5d:96 Hardware Port: Thunderbolt 1 Device: en2 Ethernet Address: c6:00:0d:31:0c:01 Hardware Port: Thunderbolt 2 Device: en3 Ethernet Address: c6:00:0d:31:0c:00 Hardware Port: Thunderbolt 3 Device: en4 Ethernet Address: c6:00:0d:31:0c:05 Hardware Port: Thunderbolt 4 Device: en5 Ethernet Address: c6:00:0d:31:0c:04 Hardware Port: Thunderbolt Bridge Device: bridge0 Ethernet Address: c6:00:0d:31:0c:01 VLAN Configurations =================== ptr:~ roothost$
好吧,原来是 Ethernet、Wi-Fi、Bluetooth、Thunderbolt等 设备使用对应的网卡文件
因为是接网线的,所以我们修改 Ethernet 以太网就有线网卡这个。
当然也可以这样:
终端输入:networksetup -setmanual en0 192.168.31.2 255.255.255.0 192.168.1.1
我表示没有测试过