route更改网卡数据流向

首先,先了解传统的网络配置命令:
  1. 使用ifconfig命令配置并查看网络接口情况
  示例1: 配置eth0的IP,同时激活设备:
  # ifconfig eth0 192.168.4.1 netmask 255.255.255.0 up
  示例2: 配置eth0别名设备 eth0:1 的IP,并添加路由
  # ifconfig eth0:1 192.168.4.2
  # route add –host 192.168.4.2 dev eth0:1
  示例3:激活(禁用)设备
  # ifconfig eth0:1 up(down)
  示例4:查看所有(指定)网络接口配置
  # ifconfig (eth0)
  2. 使用route 命令配置路由表
  示例1:添加到主机路由
  # route add –host 192.168.4.2 dev eth0:1
  # route add –host 192.168.4.1 gw 192.168.4.250
  示例2:添加到网络的路由
  # route add –net IP netmask MASK eth0
  # route add –net IP netmask MASK gw IP
  # route add –net IP/24 eth1
  示例3:添加默认网关
  # route add default gw IP
  示例4:删除路由
  # route del –host 192.168.4.1 dev eth0:1
  示例5:查看路由信息
  # route 或 route -n (-n 表示不解析名字,列出速度会比route 快)


实践脚本

#! /bin/sh

route add -host 192.168.0.12 dev eth0

route add -host 192.168.1.137 dev eth0

route add -host 192.168.0.192 dev eth1

route del default

route del default

route del -net 192.168.0.0 netmask 255.255.0.0 eth0

route del -net 192.168.0.0 netmask 255.255.0.0 eth1

ctdb集群的samba    serverroute控制脚本

 

#! /bin/sh

route del default

route del default

route del -net 192.168.0.0 netmask 255.255.0.0 eth0

route del -net 192.168.0.0 netmask 255.255.0.0 eth1

route add -net 192.168.0.0 netmask 255.255.0.0  eth0

route add -net 192.168.1.0 netmask 255.255.255.0  eth1

route add default gw 192.168.1.1


210route

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.0.12    *               255.255.255.255 UH    0      0        0 eth0

192.168.0.22    *               255.255.255.255 UH    0      0        0 eth0

192.168.0.111   *               255.255.255.255 UH    0      0        0 eth0

192.168.0.112   *               255.255.255.255 UH    0      0        0 eth0

192.168.0.113   *               255.255.255.255 UH    0      0        0 eth1

192.168.0.114   *               255.255.255.255 UH    0      0        0 eth1

192.168.1.0     *               255.255.255.0   U     0      0        0 eth1

转载于:https://my.oschina.net/zphj1987/blog/79185

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值