zoukankan      html  css  js  c++  java
  • centos 路由配置

    主机路由
    主机路由是路由选择表中指向单个IP地址或主机名的路由记录。主机路由的Flags字段为H。例如,在下面的示例中,本地主机通过IP地址192.168.1.1的路由器到达IP地址为10.0.0.10的主机。
    Destination Gateway Genmask Flags Metric Ref Use Iface
    ----------- ------- ------- ----- ------ --- --- -----
    10.0.0.10 192.168.1.1 255.255.255.255 UH 0 0 0 eth0
    网络路由
    网络路由是代表主机可以到达的网络。网络路由的Flags字段为N。例如,在下面的示例中,本地主机将发送到网络192.19.12的数据包转发到IP地址为192.168.1.1的路由器。
    Destination Gateway Genmask Flags Metric Ref Use Iface
    ----------- ------- ------- ----- ----- --- --- -----
    192.19.12 192.168.1.1 255.255.255.0 UN 0 0 0 eth0
    默认路由
    当主机不能在路由表中查找到目标主机的IP地址或网络路由时,数据包就被发送到默认路由(默认网关)上。默认路由的Flags字段为G。例如,在下面的示例中,默认路由是IP地址为192.168.1.1的路由器。
    Destination Gateway Genmask Flags Metric Ref Use Iface
    ----------- ------- ------- ----- ------ --- --- -----
    default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
    配置静态路由
    route 命令
    设置和查看路由表都可以用 route 命令,设置内核路由表的命令格式是:
    # route [add|del] [-net|-host] target [netmask Nm] [gw Gw] [[dev] If]
    其中:
    • add : 添加一条路由规则
    • del : 删除一条路由规则
    • -net : 目的地址是一个网络
    • -host : 目的地址是一个主机
    • target : 目的网络或主机
    • netmask : 目的地址的网络掩码
    • gw : 路由数据包通过的网关
    • dev : 为路由指定的网络接口
    route 命令使用举例
    添加到主机的路由
    # route add -host 192.168.1.2 dev eth0:0
    # route add -host 10.20.30.148 gw 10.20.30.40

    添加到网络的路由
    # route add -net 10.20.30.40 netmask 255.255.255.248 eth0
    # route add -net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
    # route add -net 192.168.1.0/24 eth1
    添加默认路由
    # route add default gw 192.168.1.1
    删除路由
    # route del -host 192.168.1.2 dev eth0:0
    # route del -host 10.20.30.148 gw 10.20.30.40
    # route del -net 10.20.30.40 netmask 255.255.255.248 eth0
    # route del -net 10.20.30.48 netmask 255.255.255.248 gw 10.20.30.41
    # route del -net 192.168.1.0/24 eth1
    # route del default gw 192.168.1.1

    **************************************************************************************
    当你的才华还撑不起你的野心的时候,你就应该静下心来学习;当你的能力还驾驭不了你的目标时,就应该沉下心来,历练;梦想,不是浮躁,而是沉淀和积累,只有拼出来的美丽,没有等出来的辉煌,机会永远是留给最渴望的那个人,学会与内心深处的你对话,问问自己,想 要怎样的人生,静心学习,耐心沉淀,送给自己,共勉。
    **************************************************************************************
  • 相关阅读:
    PythonStudy——os 操作系统 模块
    PythonStudy——sys:系统 模块
    PythonStudy——datatime 模块
    PythonStudy——calendar 模块
    PythonStudy——time 模块
    PythonStudy——shelve 模块
    PythonStudy——hashlib 模块
    PythonStudy——hmac 模块
    JDK的版本历史
    Zookeeper分布式协调服务
  • 原文地址:https://www.cnblogs.com/macoffee/p/13374932.html
Copyright © 2011-2022 走看看