Debian如何永久添加静态路由
在RedHat(RHEL)/CentOS/Fedora Linux环境永久添加静态路由通常是写在诸如/etc/sysconfig/network-scripts/route-eth0这些文件里。在Debian下有所不同,我们会把这些添加路由的脚本放到/etc/network/interfaces里执行。如下面的例子:
auto eth0 iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.254 up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1 down route del -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1
具体可参考man 5 interfaces以及示例文件/etc/network/interfaces(可能需要解压)