Chinaunix首页 | 论坛 | 博客
  • 博客访问: 133629
  • 博文数量: 58
  • 博客积分: 1411
  • 博客等级: 上尉
  • 技术积分: 750
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-25 11:41
文章分类
文章存档

2010年(20)

2009年(37)

2008年(1)

我的朋友

分类: LINUX

2009-04-20 16:40:14

Redhat 改默认网关、改静态路由的超详细步骤

0. 简单说改默认网关是改 /etc/sysconfig/network 中的 GATEWAY 配置
改静态路由是改 /etc/sysconfig/network-scripts/ 目录的 eth?.route or route-eth?
详细提醒如下

1. 检查内外网流量 是否流量很大正在提供重要服务
得到相关人员确认后再行动

2. 确认是要改的机器
ifconfig (或 ip ad ls) 确认当前所在机器

3. route -n (或 ip route ls) 查看当前默认网关和配置
/etc/sysconfig/network
GATEWAY=当前.配置.网关.ip

4. 确认内外网卡配置 ONBOOT 配置 (eth0 eth1 ... 都要看)
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1

5. 确认内外网默认路由配置 (eth0 eth1 ... 都要看)
/etc/sysconfig/network-scripts/eth1.route

/etc/sysconfig/network-scripts/route-eth1
最好再确认一眼 /etc/sysconfig/static-routes
确认 rc.local 配置 (加上所有自启动服务检查更好)

6. [可选] [高级]确认是否启用了策略路由
ip rule ls 确认有没有自定义 table 路由策略

7. [可选] 确认所有定时任务没有改 ip 路由等配置
比如远程更新网卡驱动 为防意外(保险)回退有时用此方法

8. 简单的修改可以用 ; 一次执行完 比如
route del default; route add default gw 新.网.关.IP
对自己不自信 可以先把自己的机器加上去 防止改错自己也连不上
route add -host 自己.机器.的.ip gw 正确.网关.的.ip

9. 大量修改用 ifup 生效 如 ifup eth1
用init脚本要用restart 如 service network restart
防止先敲 service network stop 回车后再想敲 service network start 的情况

A. 适用于 Redhat 发行版, 转载请注明

相关文章:

三种方式:
eth0.route redhat 新推的格式 比较傻瓜一些
route-eth0 redhat 的老的格式 对专业人士很好
static-routes

举例如下:
/etc/sysconfig/network-scripts/eth0.route
ADDRESS0=192.168.0.0
NETMASK0=255.255.0.0
GATEWAY0=10.1.1.254
ADDRESS1=172.16.0.0
NETMASK1=255.240.0.0
GATEWAY1=10.1.1.254

/etc/sysconfig/network-scripts/route-eth0
192.168.0.0/16 via 10.1.1.254
172.16.0.0/12 via 10.1.1.254

/etc/sysconfig/static-routes
eth0 net 192.168.0.0 netmask 255.255.0.0 gw 10.1.1.254

阅读(1543) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~