首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

Linux如何添加路由_linux添加永久路由命令

大家好,又见面了,我是你们的朋友全栈君。 Linux如何添加路由 a.如何使用命令给Linux添加一个默认网关? 缺省网关路由: 默认网关就是数据包不匹配任何的路由规则,最后流经的地址关口!网关按字面意思就是网络的关口 ,就相当于我们办公室的大门一样,大家上班就要经过办公室的门一样。 使用route -n 查看网关信息,或者 netstat -rn查看路由 [root@machine1 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 如何删除路由表: [root@machine1 ~]# route del default gw 192.168.0.1 [root@machine1 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 配置方法: 1、setup 2、配置网卡配置文件:/etc/sysconfig/network-scripts/ifcfg-eth0 关键字:GATEWAY=192.168.0. 重启网卡配置生效 3、route add default gw 192.168.0.1 #(临时生效) [root@machine1 ~]# route add default gw 192.168.0.1 [root@machine1 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 如何添加网络路由? b.网络路由:即去往某个网段的路由 一般多个网段之间相互通信,希望建立一条优先的路由,而不是通过默认的网关。拿家里来说, 你要去卫生间有卫生间的门,去卧室有卧室的门。这两个门就是网络路由了。家里的大门呢,就是 默认路由。

01
领券