拉赫尔5.x
我很习惯通过/etc/sysconfig/static-routes添加静态路径。然而,当我回顾红帽文件时,我没有看到提到这一点。相反,建议使用/etc/sysconfig/network-scripts/route-<interface>
static-routes文件是否是添加持久路由的不推荐方法?
发布于 2015-12-24 08:06:00
如果您关闭了一个接口,那么使用该接口的任何路由都将被删除。这是在内核中自动发生的。
如果再次启动接口,/etc/sysconfig/static-routes将不会再次运行,因此该文件中为该接口指定的路由将丢失。但是,如果您将路由放置在特定于接口的文件中,那么当您再次打开接口时,它们将被系统还原。
因此,最好将路由放在/etc/sysconfig/network-scripts/route-<interface>文件中。
发布于 2015-12-23 17:46:44
该文件看起来像是包含非接口特定的静态路由,通过一些在/etc下浏览的方式:
# grep -rl static-route .
./rc.d/init.d/network
./ppp/ipv6-up
./ppp/ip-up.ipv6to4
./sysconfig/network-scripts/ifup-sit
./sysconfig/network-scripts/ifup-ipv6
# perl -00 -ne 'print if m/static-routes/' rc.d/init.d/network
# Add non interface-specific static-routes.
if [ -f /etc/sysconfig/static-routes ]; then
grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
/sbin/route add -$args
done
fi
# Add non interface-specific static arp entries.
if [ -f /etc/ethers ]; then
/sbin/arp -f /etc/ethers
fi这些文件存在于RHEL5、6和7上,但是如果禁用了network服务,则可能不会运行这些文件,因为我不知道NetworkManager是否引用了static-routes文件;这需要实际启用它,并且可能需要在strace -o blah -ff -e trace=file ...下运行它来查看它所涉及的内容。
https://unix.stackexchange.com/questions/251184
复制相似问题