Chinaunix首页 | 论坛 | 博客
  • 博客访问: 112639
  • 博文数量: 29
  • 博客积分: 1440
  • 博客等级: 上尉
  • 技术积分: 371
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-03 15:57
文章分类

全部博文(29)

文章存档

2011年(5)

2010年(1)

2009年(23)

我的朋友

分类:

2009-06-17 11:21:31

linux下添加路由的方法:
  一:使用 route 命令添加

  使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法:

  //添加到主机的路由
  # route add –host 192.168.168.110 dev eth0
  # route add –host 192.168.168.119 gw 192.168.168.1

  //添加到网络的路由
  # route add –net IP netmask MASK eth0
  # route add –net IP netmask MASK gw IP
  # route add –net IP/24 eth1

  //添加默认网关
  # route add default gw IP

  //删除路由
  # route del –host 192.168.168.110 dev eth0

  二:在linux下设置永久路由的方法:

  1.在/etc/rc.local里添加

  方法:
  route add -net 192.168.3.0/24 dev eth0
  route add -net 192.168.2.0/24 gw 192.168.3.254
  
   <常用>
      例:touch /var/lock/subsys/local
 
       route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.*.1 dev eth0
 
  2.在/etc/sysconfig/network里添加到末尾
  方法:GATEWAY=gw-ip 或者 GATEWAY=gw-dev

  3./etc/sysconfig/static-router :
  any net x.x.x.x/24 gw y.y.y.y
阅读(496) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~