Mac电脑如何设置DHCP
通过设置MAC电脑的DHCP服务器可以为局域网内的其它设备自动分配IP地址,还能把物理地址和IP地址绑定起来,限制IP地址的获取。
b)点击 Utilities > Terminal
c)在 Terminal 中输入 csrutil disable,之后回车
d)重启 Mac
-
-
-
<plist version="1.0">
-
<dict>
-
<key>Disabled</key>
-
<true/>
-
<key>Label</key>
-
<string>com.apple.bootpd</string>
-
<key>Program</key>
-
<string>/usr/libexec/bootpd</string>
-
<key>ProgramArguments</key>
-
<array>
-
<string>/usr/libexec/bootpd</string>
-
<string>-Dv</string>
-
</array>
-
<key>Sockets</key>
-
<dict>
-
<key>Listeners</key>
-
<dict>
-
<key>SockFamily</key>
-
<string>IPv4</string>
-
<key>SockServiceName</key>
-
<string>bootps</string>
-
<key>SockType</key>
-
<string>dgram</string>
-
</dict>
-
</dict>
-
<key>inetdCompatibility</key>
-
<dict>
-
<key>Wait</key>
-
<true/>
-
</dict>
-
</dict>
-
</plist>
3)加载启动脚本命令:sudo /bin/launchctl load -w /System/Library/LaunchDaemons/bootps.plist
4)去除启动脚本命令:sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/bootps.plist
设置bootpd的运行方式
1)bootpd有两个配置文件,一个是bootps.plist用于指导dhcp和bootp服务的工作方式,另一个是bootptab,用于设置地址池。(注意,此处的bootps.plist与上一个步骤的plist文件同名,但作用完全不同,前者的目的是设置开机启动bootpd程序,本文件的目地是指导bootpd程序的运行方式)
2)bootps.plist的路径:/etc/bootps.plist
3)bootps.plist配置文件内容:
-
-
-
<plist version="1.0">
-
<dict>
-
<key>Subnets</key>
-
<array>
-
<dict>
-
<key>allocate</key>
-
<true/>
-
<key>allow</key>
-
<array>
-
<string>8C:FA:BA:01:E6:F3</string>
-
<string>6C:FD:B9:C8:7E:2B</string>
-
<string>B8:09:8A:83:22:A3</string>
-
<string>10:dd:b1:c6:b4:37</string>
-
<string>60:92:17:A2:C2:65</string>
-
<string>E0:06:E6:1B:AE:A0</string>
-
<string>E8:8D:28:DF:13:0C</string>
-
<string>64:09:80:D8:5B:98</string>
-
<string>b8:98:f7:11:a4:79</string>
-
<string>70:72:3C:53:CE:BA</string>
-
<string>00:0a:f5:10:fb:2c</string>
-
<string>b8:98:f7:aa:1e:0d</string>
-
<string>28:b2:bd:af:07:62</string>
-
<string>68:3e:34:4c:ca:cb</string>
-
<string>9C:44:3D:1E:68:F4</string>
-
<string>A8:15:4D:F5:4A:AC</string>
-
<string>68:3e:34:4c:ca:cb</string>
-
<string>54:EE:75:27:6C:D4</string>
-
</array>
-
<key>dhcp_domain_name</key>
-
<string>ns1.drugsales.com</string>
-
<key>dhcp_domain_name_server</key>
-
<string>192.168.1.1</string>
-
<key>dhcp_router</key>
-
<string>192.168.1.1</string>
-
<key>lease_max</key>
-
<integer>86400</integer>
-
<key>lease_min</key>
-
<integer>86400</integer>
-
<key>name</key>
-
<string>vulcan</string>
-
<key>net_address</key>
-
<string>192.168.1.0</string>
-
<key>net_mask</key>
-
<string>255.255.255.0</string>
-
<key>net_range</key>
-
<array>
-
<string>192.168.1.100</string>
-
<string>192.168.1.200</string>
-
</array>
-
</dict>
-
</array>
-
<key>bootp_enabled</key>
-
<false/>
-
<key>detect_other_dhcp_server</key>
-
<integer>1</integer>
-
<key>dhcp_enabled</key>
-
<array>
-
<string>en0</string>
-
</array>
-
<key>reply_threshold_seconds</key>
-
<integer>0</integer>
-
</dict>
-
</plist>
-
%%
-
# machine entries have the following format:
-
#
-
# hostname hwtype hwaddr ipaddr bootfile
-
vulcan-macmini 1 10:dd:b1:c6:b4:37 192.168.1.2
-
vulcan-iphone5s 1 60:92:17:A2:C2:65 192.168.1.100
-
tangling-pc 1 E0:06:E6:1B:AE:A0 192.168.1.101
-
tangling-iphone5 1 E8:8D:28:DF:13:0C 192.168.1.102
-
tangMum-xiaomi 1 64:09:80:D8:5B:98 192.168.1.103
-
iPad3 1 8C:FA:BA:01:E6:F3 192.168.1.104
-
vulcan-huawei 1 70:72:3C:53:CE:BA 192.168.1.105
-
vulcan-u2 1 00:0a:f5:10:fb:2c 192.168.1.106
-
vulcan-u4 1 b8:98:f7:aa:1e:0d 192.168.1.107
-
vulcan-win8-wifi 1 28:b2:bd:af:07:62 192.168.1.108
-
vulcan-win8-eth 1 54:EE:75:27:6C:D4 192.168.1.109
-
mum-mobile 1 d0:2d:b3:8e:48:4c 192.168.1.110
-
vulcan-meilan 1 68:3e:34:4c:ca:cb 192.168.1.111
-
android-tvbox 1 9C:44:3D:1E:68:F4 192.168.1.112
-
yangzhenxue-iphone5s 1 B8:09:8A:83:22:A3 192.168.1.113
-
yangzhenxue-hasee 1 6C:FD:B9:C8:7E:2B 192.168.1.114
6)使用苹果系统自带的“控制台”工具程序可以查看bootpd的运行日志。
7)bootpd的日志文件输出到/var/log/system.log文件中。
如果输出以下调试信息,恭喜你,这说明bootpd的启动是没有问题的:
Jan 4 00:05:16 bogon bootpd[3185]: server starting
Jan 4 00:05:16 bogon bootpd[3185]: re-reading /etc/bootptab
Jan 4 00:05:16 bogon bootpd[3185]: Loaded 16 entries from bootptab (0 bad)
Jan 4 00:05:16 bogon bootpd[3185]: server name bogon
Jan 4 00:05:16 bogon bootpd[3185]: interface en0: ip 192.168.1.2 mask 255.255.255.0
常见错误信息:
1.bootpd[1091]: bind call failed: Permission denied
2.bootpd[1290]: bind call failed: Address already in use,说明地址已经被绑定,很可能有bootpd的另一个实例在运行。