macos Mac OS X 中的 DHCP 设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/316574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DHCP Setting in Mac OS X
提问by benc
Are there any command line interfaces to the DHCP settings in Mac OS X? I have found that inside System Profiler, the Network tab provides a lot of useful information, but I have not found any documentation about any command line equivalents.
Mac OS X 中的 DHCP 设置是否有任何命令行界面?我发现在 System Profiler 中,网络选项卡提供了很多有用的信息,但我没有找到任何有关任何命令行等效项的文档。
回答by Arne Burmeister
You may use
您可以使用
networksetup -listallnetworkservices
networksetup -getinfo <networkservice>
networksetup -setdhcp <networkservice> [clientid]
networkservice is something like Ethernet (all availabe listed by the first command)
networkservice 有点像以太网(第一个命令列出了所有可用的东西)
回答by tegbains
You can also use:
您还可以使用:
ipconfig getpacket `interface`
where interface would be en0, en1
etc.
接口在哪里en0, en1
等。
ie:
IE:
ipconfig getpacket en1
op = BOOTREPLY
htype = 1
flags = 0
hlen = 6
hops = 0
xid = 215448168
secs = 3
ciaddr = 0.0.0.0
yiaddr = 192.168.15.121
siaddr = 0.0.0.0
giaddr = 0.0.0.0
chaddr = 0:19:e3:6:70:95
sname =
file =
options:
Options count is 8
dhcp_message_type (uint8): ACK 0x5
server_identifier (ip): 192.168.15.1
lease_time (uint32): 0xa8c0
subnet_mask (ip): 255.255.255.0
router (ip_mult): {192.168.15.1}
domain_name_server (ip_mult): {192.168.15.249, 192.168.15.240}
domain_name (string): domain.com
end (none):
You can also do:
你也可以这样做:
ipconfig getoption en0 optionname
ie: ipconfig getoption en1 router
IE: ipconfig getoption en1 router
192.168.15.1
回答by Jason Coco
You should look at:
你应该看看:
ifconfig(8)
netstat(1)
netintro(4)
The most important of these (netintro isn't actually a utility but rather introductory information on unix networking) is ifconfig which is the command line tool used to configure the various network interfaces you may have installed on your machine (like your ethernet card and your airport card) as well as any virtual interfaces (like your loopback address and things like parallels).
其中最重要的(netintro 实际上不是一个实用程序,而是 unix 网络的介绍性信息)是 ifconfig,它是一个命令行工具,用于配置您可能已安装在您的机器上的各种网络接口(如您的以太网卡和您的机场卡)以及任何虚拟接口(比如你的环回地址和类似并行的东西)。