linux添加永久路由(命令行添加永久路由),本文通过数据整理汇集了linux添加永久路由(命令行添加永久路由)相关信息,下面一起看看。
linux下添加路由的方法;
一:使用route命令添加
使用route命令添加路由,重启机器或重启网卡后路由无效。方法:
//路由添加到主机# route Addhost 192 . 168 . 168 . 110 devieth 0 # route Addhost 192 . 168 . 119 GW 192 . 168 . 168 . 1//路由添加到网络# route Addnet IP网络掩码eth 0 # Addnet IP网络掩码掩码GW IP # route Addnet IP/24et h1//添加默认网关# routeaddefaultgwip//删除路由# route delhost 192.1
1.add in/etc/rc.local
方法:
Add-net 192 . 168 . 3 . 0/24 devith 0 route Add-net 192 . 168 . 2 . 0/24gw 192 . 168 . 3 . 2542 .添加到/etc/sysconfig/network中的末尾。
方法:网关=gw-ip或网关=gw-dev
3./etc/sysconfig/static-router:
Net x.x.x.x/24GW y.y.y.y Linux添加永久静态路由
Linux的路由功能:
重新启动机器或重新启动网卡后,由# route命令添加的路由不会丢失。如何在linux下设置永久路由:
1.add in/etc/rc.local
2.添加到/etc/sysconfig/network中的末尾
3./etc/sysconfig/static-router:
任何净x.x.x.x/24 gw年同比
打开IP转发:
# echo 1 /proc/sys/net/IP v4/IP _ forward(临时)# VI/etc/sysctl . conf-net . IP v4 . IP _ forward=1(永久开启)
更多linux添加永久路由(命令行添加永久路由)相关信息请关注本站,本文仅仅做为展示!