我无法让静态路由在 Mac OS 10.6.5 上重启后继续生效。我尝试了 Google 搜索结果和此网站之前的帖子中介绍的所有方法。我尝试过手动创建 launchd 守护程序,并使用 RouteSplit 的 launchd 守护程序,但无济于事。很明显,当这些方法尝试应用路由时,接口尚未准备好。有问题的工作站从 DHCP 获取其 IP,并且在命令运行时可能尚未获得其 DHCP 租约。我们可以在登录时手动应用路由,但不能通过启动方法应用。是否有其他方法可以应用此路由,即稍后但在登录窗口出现在用户面前之前将命令偷偷放入某个东西中?
以下是来自 system.log 的一些相关日志信息。在我的 launchd 脚本启动时,您可以看到“route: writing to routing socket: Network is unreachable”错误。我尝试在脚本后面添加额外的“sleep”和“ipconfig waitall”语句,但不起作用。
Dec 15 19:30:41 localhost com.apple.launchd[1]: *** launchd[1] has started up. ***
Dec 15 19:30:45 localhost mDNSResponder[18]: mDNSResponder mDNSResponder-258.13 (Oct 8 2010 17:10:30) starting
Dec 15 19:30:47 localhost configd[15]: bootp_session_transmit: bpf_write(en1) failed: Network is down (50)
Dec 15 19:30:47 localhost configd[15]: DHCP en1: INIT transmit failed
Dec 15 19:30:47 localhost configd[15]: network configuration changed.
Dec 15 19:30:47 Administrators-MacBook-Pro configd[15]: setting hostname to "Administrators-MacBook-Pro.local"
Dec 15 19:30:47 Administrators-MacBook-Pro blued[16]: Apple Bluetooth daemon started
Dec 15 19:30:52 Administrators-MacBook-Pro syslog[67]: routes.sh: Starting RouteSplit
Dec 15 19:30:53 Administrators-MacBook-Pro com.apple.usbmuxd[41]: usbmuxd-207 built for iTunesTenOne on Oct 19 2010 at 13:50:35, running 64 bit
Dec 15 19:30:54 Administrators-MacBook-Pro /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow[50]: Login Window Application Started
Dec 15 19:30:55 Administrators-MacBook-Pro bootlog[61]: BOOT_TIME: 1292459441 0
Dec 15 19:30:55 Administrators-MacBook-Pro syslog[86]: routes.sh: static route 192.168.0.0/23 192.168.2.2
Dec 15 19:30:55 Administrators-MacBook-Pro net.routes.static[65]: route: writing to routing socket: Network is unreachable
Dec 15 19:30:55 Administrators-MacBook-Pro net.routes.static[65]: add net 192.168.0.0: gateway 192.168.2.2: Network is unreachable
Dec 15 19:30:57 Administrators-MacBook-Pro org.apache.httpd[38]: httpd: Could not reliably determine the server's fully qualified domain name, using Administrators-MacBook-Pro.local for ServerName
Dec 15 19:30:58 Administrators-MacBook-Pro loginwindow[50]: Login Window Started Security Agent
Dec 15 19:30:58 Administrators-MacBook-Pro WindowServer[89]: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Dec 15 19:30:58 Administrators-MacBook-Pro com.apple.WindowServer[89]: Wed Dec 15 19:30:58 Administrators-MacBook-Pro.local WindowServer[89] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Dec 15 19:31:18 Administrators-MacBook-Pro configd[15]: network configuration changed.
Dec 15 19:31:19 administrators-macbook-pro configd[15]: setting hostname to "administrators-macbook-pro.local"
Dec 15 19:31:25 administrators-macbook-pro _mdnsresponder[121]: /usr/libexec/ntpd-wrapper: scutil key State:/Network/Global/DNS not present after 30 seconds
Dec 15 19:31:25 administrators-macbook-pro _mdnsresponder[124]: sntp options: a=2 v=1 e=0.100 E=5.000 P=2147483647.000
Dec 15 19:31:25 administrators-macbook-pro _mdnsresponder[124]: d=15 c=5 x=0 op=1 l=/var/run/sntp.pid f= time.apple.com
Dec 15 19:31:25 administrators-macbook-pro _mdnsresponder[124]: sntp: getaddrinfo(hostname, ntp) failed with nodename nor servname provided, or not known
Dec 15 19:31:27 administrators-macbook-pro configd[15]: network configuration changed.
Dec 15 19:31:27 Administrators-MacBook-Pro configd[15]: setting hostname to "Administrators-MacBook-Pro.local"
Dec 15 19:31:27 Administrators-MacBook-Pro ntpd[37]: Cannot find existing interface for address 17.151.16.20
Dec 15 19:31:27 Administrators-MacBook-Pro ntpd_initres[125]: ntpd indicates no data available!
Dec 15 19:31:31 Administrators-MacBook-Pro sshd[128]: USER_PROCESS: 133 ttys000
Dec 15 19:31:37 Administrators-MacBook-Pro sudo[138]: administrator : TTY=ttys000 ; PWD=/Users/administrator ; USER=root ; COMMAND=/usr/bin/less /var/log/system.log
“您可以在 /var/log/kernel.log 中看到以下行,显示 en0 接口即将启动:
Dec 15 19:30:51 Administrators-MacBook-Pro kernel[0]: Ethernet [AppleBCM5701Ethernet]: Link up on en0, 1-Gigabit, Full-duplex, No flow-control, Debug [796d,0f01,0de1,0300,c1e1,3800]
答案1
将 launchd plist 设置为由指向 的“WatchPath”键触发/Library/Preferences/SystemConfiguration
。我认为每当分配新 IP 时,此文件都会更改。不是在启动时启动,而是每次 IP 配置更改时启动,还有一个额外的好处,就是能够根据您的子网决定是否拆分。