• 配置默认网关


    第一生效文件:/etc/sysconfig/network-scripts/ifcfg-eth0

    [root@newname ~]# grep -i gate /etc/sysconfig/network-scripts/ifcfg-eth3GATEWAY=192.168.0.1

    第二生效文件:/etc/sysconfig/network

    [root@newname ~]# grep -i gate /etc/sysconfig/network
    GATEWAY=192.168.0.1

    查看路由命令:route -n,或netstat -rn

    [root@oldboy ~]# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
    192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth3
    169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth3
    0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth3
    [root@oldboy ~]# netstat -rn
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0
    192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth3
    169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth3
    0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 eth3

    其中,最后一行为默认网关,不管去哪个网络,都从默认网关192.168.0.1出去。

    设置(添加和删除,屏蔽)路由:命令行优先,且临时生效:

    添加默认网关 为10.0.0.1
    root@text:~# route add default gw 10.0.0.1
    删除默认网关
    root@text:~# route del default gw 10.0.0.1
    
    添加到主机的路由
    root@text:~# route add -host 192.168.10.2 dev eth3
    root@text:~# route -n
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.10.2     *               255.255.255.255 UH    0      0        0 eth3
    删除到主机的路由
    root@text:~# route del -host 192.168.10.2 dev eth3
    
    添加到网络192.168.55.0的路由
    root@text:~# route add -net 192.168.55.0 netmask 255.255.255.0 eth3
    屏蔽到网路192.168.55.0的路由
    route add -net 192.168.55.0 netmask 255.255.255.0 reject
    
    删除到网络的路由
    root@text:~# route del -net 192.168.55.0 netmask 255.255.255.0 eth3
  • 相关阅读:
    【转载】Spring各jar包详解
    Docker attach卡着的解决
    三张图搞透第一范式(1NF)、第二范式(2NF)和第三范式(3NF)的区别
    决策表
    因果图与决策表法
    边界值分析法
    黑盒测试方法
    软件测试的基本流程
    软件测试原则
    软件测试与软件开发
  • 原文地址:https://www.cnblogs.com/zoe233/p/11904375.html
Copyright © 2020-2023  润新知