Mac電腦如何設定DHCP
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <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配置檔案內容:
4)bootptab檔案內容(路徑也是/etc/bootptab):<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <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
5)手動啟動bootpd的命令:bootpd -Ddv,D表示要啟動DHCP模式,d表示前臺執行並把除錯資訊重定向到標準輸出,v表示輸出更加全面的除錯資訊。
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的另一個例項在執行。