我为静态路由创build了一些脚本,称为“my.rc.route”,并将其放在/etc/rc.local中,因此每次服务器重新启动时,脚本都应在所有启动过程之后运行。
我觉得有点奇怪,发现我的脚本上有一行被系统忽略,随机。
任何人处理这种情况? 在哪里跟踪/login阅读?
我在这里粘贴我的“my.rc.route”,Gnudiff回答。
#!/bin/bash ip ro add table arieluna 10.254.254.248/29 dev lan proto kernel scope link src 10.254.254.254 ip ro add table arieluna 10.222.23.0/24 dev vlan17 proto kernel scope link src 10.222.23.1 ip ro add table arieluna 10.222.22.0/24 dev vlan16 proto kernel scope link src 10.222.22.1 ip ro add table arieluna 10.222.21.0/24 dev vlan15 proto kernel scope link src 10.222.21.1 ip ro add table arieluna 10.222.20.0/24 dev vlan14 proto kernel scope link src 10.222.20.1 ip ro add table arieluna 10.222.19.0/24 dev vlan13 proto kernel scope link src 10.222.19.1 ip ro add table arieluna 10.222.18.0/24 dev vlan12 proto kernel scope link src 10.222.18.1 ip ro add table arieluna 10.222.17.0/24 dev vlan11 proto kernel scope link src 10.222.17.1 ip ro add table arieluna 10.222.16.0/24 dev vlan10 proto kernel scope link src 10.222.16.1 ip ro add table arieluna 10.222.24.0/24 dev vlan18 proto kernel scope link src 10.222.24.1
@Redmumba在这里是正确的道路。 如果您尝试为尚未configuration的接口添加iptables规则,则iptables将引发错误,并且不会添加规则。 这听起来像你至less要通过NetworkManager或类似的东西configuration你的接口之一(取决于你的发行版),只有当用户通过GUIlogin(即执行rc.local 后 )才会发生该部分。
如果你希望这样做,你需要通过/ etc / network / interfaces(你是基于Debian的发行版)或类似机制中的“up”命令来执行脚本。
或者,您可以将您的接口configuration为在引导时进行configuration。 在基于Debian的发行版中,这是通过将接口节中的“allow-hotplug”关键字replace为“auto”来完成的。 其他发行版将使用其他机制,你将不得不阅读相关的手册页来找出做什么。