文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>修改linux静态路由

修改linux静态路由

时间:2007-04-11  来源:lusec3

  修改Linux静态路由

 

内网:有两个网段10.10.100.0/24和10.10.101.0/24,

 

服务器ip: a.b.c.d   外网网关e.f.g.h  服务器内网卡10.10.100.254

 

内网10.10.101.0/24网段的机器无法访问10.10.100.254这台机器。

 

登陆服务器查看路由表:

[root@www conf]# netstat -r

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

10.10.100.0     *               255.255.255.0   U         0 0          0 eth0

169.254.0.0     *               255.255.0.0     U         0 0          0 eth1

default         e.f.g.h    0.0.0.0         UG        0 0          0 eth1  

 

因此可以看到在10.10.100.254服务器上无法看到10.10.101.0/24的路由选择表路由条目,因此可以两种方法添加,

临时性的:

route add -net  10.10.101.0  netmask 255.255.255.0 gw 10.10.100.1

 

但重新启动后就会失效.因此在/etc/sysconfig/network-scripts/目录下建立文件。因为我们是做内网的路由,并且内网网卡为eth0,因此我们建立route-eth0文件如下:

[root@www network-scripts]# cat route-eth0

10.10.101.0/24 via 10.10.100.1 dev eth0

[root@www network-scripts]# /etc/rc.d/init.d/network restart启动生效

 

[root@www network-scripts]# netstat -r

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

10.10.101.0     10.10.100.1     255.255.255.0   UG        0 0          0 eth0

10.10.100.0     *               255.255.255.0   U         0 0          0 eth0

169.254.0.0     *               255.255.0.0     U         0 0          0 eth1

default         e.f.g.h    0.0.0.0         UG        0 0          0 eth1

 

 

 

修改外网网关如下:

[root@www conf]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=www.test.cn

GATEWAY=e.f.g.h  

 

相关阅读 更多 +
排行榜 更多 +
奇境小镇MOD作弊菜单

奇境小镇MOD作弊菜单

角色扮演 下载
黑暗荒野2无限金币版

黑暗荒野2无限金币版

角色扮演 下载
骑战烈火之剑作弊菜单版

骑战烈火之剑作弊菜单版

角色扮演 下载