zoukankan      html  css  js  c++  java
  • route 相关设置

    Debian系统

    查看路由表:

    root@debian:~# ip route
    default via 192.168.6.1 dev enp4s0 
    10.0.0.0/24 dev br0 proto kernel scope link src 10.0.0.1 linkdown 
    192.168.6.0/24 dev enp4s0 proto kernel scope link src 192.168.6.20 
    

      

    Debian / Ubuntu Linux static routing for two interfaces:

    Here is a config file named /etc/network/interfaces:

    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 10.9.38.76
            netmask 255.255.255.240
            network 10.9.38.64
            broadcast 10.9.38.79
    	### static routing for eth0 that connects to the VLAN ###
            post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.9.38.65
            pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 10.9.38.65
    
    auto eth1
    iface eth1 inet static
            address 204.186.149.140
            netmask 255.255.255.240
            network 204.186.149.128
            broadcast 204.186.149.143
            ## default gateway for eth1 and the server ##
            gateway 204.186.149.129
            # dns-* options are implemented by the resolvconf package, if installed
            dns-nameservers 10.0.80.11 10.0.80.12
            dns-search nixcraft.in
    

      

    ip command to set a default router to 192.168.1.254

    # ip route add default via 192.168.1.254
    

      

    route command to set a default router to 192.168.1.254

     route add default gw 192.168.1.254
    

      

    Save routing information to a configuration file /etc/network/interfaces

    Open /etc/network/interfaces file

    # vi /etc/network/interfaces
    

    Find eth0 or desired network interface and add following option

    gateway 192.168.1.254 

    Save and close the file. Restart networking:

    # /etc/init.d/networking restart
    

     

    A note about ip command and persistence static routing on a Debian/Ubuntu

    Edit your /etc/network/interfaces file for say eth0:

    # vi /etc/network/interfaces

    Update it as follows:

    auto eth0
    iface eth0 inet static
    address 192.168.1.2
    netmask 255.255.255.0
    gateway 192.168.1.254
    ## static ip config START ##
    up /sbin/ip route add 172.10.1.0/24 via 10.8.0.1 dev eth0
    down /sbin/ip route delete 172.10.1.0/24 via 10.8.0.1 dev eth0
    ## static ip config END ##
    

      

     

    Restart networking service when using a Debian or Ubuntu Linux

    # systemctl restart networking
    

      

     

  • 相关阅读:
    HDU 1982 Kaitou Kid The Phantom Thief (1)
    HDU 1984 Mispelling4
    HDU 2546 饭卡
    HDU 1009 FatMouse' Trade
    在VC 中如何隐藏一个主程序窗口
    .菜单项
    SetClassLong,GetClassLong 动态改变光标
    .窗口捕获鼠标
    .主窗口向子控件发送消息
    线段树 1698 Just a Hook 区间set更新
  • 原文地址:https://www.cnblogs.com/saryli/p/11854686.html
Copyright © 2011-2022 走看看