Macos 如何在MAC OSX中启动时将所有网络适配器或接口禁用为关闭状态
我不熟悉MAC架构。 我需要在系统启动期间禁用所有网络适配器。 我不知道该怎么解决 可以添加如下命令吗 sudo-ifconfig-en0向下; sudo ifconfig en1关闭 进入启动脚本??或 最好编写守护进程 请给我建议一些解决这个问题的好办法Macos 如何在MAC OSX中启动时将所有网络适配器或接口禁用为关闭状态,macos,Macos,我不熟悉MAC架构。 我需要在系统启动期间禁用所有网络适配器。 我不知道该怎么解决 可以添加如下命令吗 sudo-ifconfig-en0向下; sudo ifconfig en1关闭 进入启动脚本??或 最好编写守护进程 请给我建议一些解决这个问题的好办法 提前感谢:)我不确定你到底想完成什么,所以要提出可靠的建议有点困难。我的理解是,OSX的接口在关闭状态下启动,然后由configd守护进程根据/Library/Preferences/SystemConfiguration/*中的配置进行配
提前感谢:)我不确定你到底想完成什么,所以要提出可靠的建议有点困难。我的理解是,OSX的接口在关闭状态下启动,然后由
configd
守护进程根据/Library/Preferences/SystemConfiguration/*中的配置进行配置和启动。因此,我认为有几种方法可以做到这一点:
- 配置网络设置以使所有接口处于非活动状态(在系统首选项->网络窗格中,或使用
命令),并让networksetup
应用它们。请注意,您必须在关机之前进行此更改,以便在启动时将其作为活动配置configd
- 在
读取网络配置之前,以某种方式在启动期间设置网络配置。这将是非常困难的,因为OSX不使用顺序启动过程;它只是启动所有各种守护进程,并让它们自己进行排序。因此,试图在configd
之前运行守护程序充其量只是一场恶作剧。(事实上,我能想出办法,但是……它们很难看。)configd
- 创建另一个守护进程,等待
激活网络接口,然后将其关闭。然后观察以确保configd
不会将其重新打开。。。哎呀configd
基本上,所有这些方法都存在问题。但是根据你的想法,可能有更好的方法。谢谢戈登 我终于找到了解决问题的办法 我使用了bash脚本+plist #禁用_internet.sh(使用chmod的行政许可) #com.disable.interent.startup.plist
<?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>Label</key>
<string>com.symantec.disable.internet</string>
<key>ProgramArguments</key>
<array>
<string>/Users/Shared/disable_internet.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>OnDemand</key>
<false/>
<key>Nice</key>
<integer>1</integer>
<key>StartInterval</key>
<integer>30</integer>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>
重新启动后,作业完成时:
sudo launchctl load -w /Library/LaunchDaemons/com.disable.interent.startup
sudo rm -rf /Library/LaunchDaemons/com.disable.interent.startup.plist
sudo ifconfig en0 up
sudo cp /Users/Shared/com.disable.interent.startup.plist /Library/LaunchDaemons/com.disable.interent.startup.plist
sudo launchctl load -w /Library/LaunchDaemons/com.disable.interent.startup
sudo launchctl load -w /Library/LaunchDaemons/com.disable.interent.startup
sudo rm -rf /Library/LaunchDaemons/com.disable.interent.startup.plist
sudo ifconfig en0 up