zoukankan      html  css  js  c++  java
  • 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.1.1
    down route del -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1

    或者

    auto eth0
    iface eth0 inet static
    address 192.168.0.10
    netmask 255.255.255.0
    gateway 192.168.0.1
    up route add -net 192.168.2.0/24 gw 192.168.0.2
    down route del -net 192.168.2.0/24 gw 192.168.0.2

     经过一番折腾发现:新版本的debian由于系统用iproute2代替的老的net-tools,要使用以上配置需要先安装net-tools,否则route命令是无效的,从而导致配置不成功。网上没有找关于debian的新配置方法,于是自己结合debian以前的配置格式和centos的配置方式,得出以下结论,经试验配置成功。

    auto eth0
    iface eth0 inet static
    address 192.168.0.10
    netmask 255.255.255.0
    gateway 192.168.0.1
    up ip route add 192.168.2.0/24 via 192.168.0.2
    down ip route del 192.168.2.0/24 via 192.168.0.2
  • 相关阅读:
    Photoshop 基础七 位图 矢量图 栅格化
    Photoshop 基础六 图层
    Warfare And Logistics UVALive
    Walk Through the Forest UVA
    Airport Express UVA
    Guess UVALive
    Play on Words UVA
    The Necklace UVA
    Food Delivery ZOJ
    Brackets Sequence POJ
  • 原文地址:https://www.cnblogs.com/surplus/p/12259716.html
Copyright © 2011-2022 走看看