Mac OS命令行修改IP地址与DNS地址

一、查看网络服务

查看网卡名称

Leon-RMBP:~ applenetworksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
USB 10/100/1000 LAN
Wi-Fi
iPhone USB
Bluetooth PAN
Thunderbolt Bridge
Leon-RMBP:~ apple 
Leon-RMBP:~ apple$ ifconfig

en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=4<VLAN_MTU>
        ether 00:e0:4c:6d:4e:ae 
        inet6 fe80::18cb:660:3495:5252%en7 prefixlen 64 secured scopeid 0xe 
        inet 192.168.34.65 netmask 0xffffff00 broadcast 192.168.34.255
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect (100baseTX <full-duplex>)
        status: active

二、设置IP地址

设置”USB 10/100/1000 LAN”静态ip

sudo networksetup -setmanual "USB 10/100/1000 LAN" 192.168.128.54 255.255.255.0 192.168.128.1

设置”USB 10/100/1000 LAN”自动获取ip

sudo networksetup -setdhcp "USB 10/100/1000 LAN"

三、查看和修改DNS

# cat /etc/resolv.conf

发表回复