zoukankan      html  css  js  c++  java
  • 配置默认网关

    第一生效文件:/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
  • 相关阅读:
    接口自动化平台
    MAC安装社区版本IDEA
    Python比较图片的不同
    快看!markdown的语法原来如此简单~
    说一说你不了解的Tailwind CSS响应式设计~
    Tailwind CSS安装和构建的正确操作方式
    一款绝对让你惊艳的CSS框架——TailwindCSS
    备受争议的PHP前景究竟如何?我们该何去何从?
    laravel8更新之速率限制改进
    laravel8更新之维护模式改进
  • 原文地址:https://www.cnblogs.com/zoe233/p/11904375.html
Copyright © 2011-2022 走看看