系统:suse 11 Linux
版本:SUSE Linux Enterprise Server 11 (i586)
VERSION = 11
VERSION = 11
PATCHLEVEL = 0
简单介绍一下配置文件方式添加静态路由的方法
配置文件路径:vim /etc/sysconfig/network/routes
按以下格式添加内容:
192.168.1.200 192.168.1.1 255.255.255.0 eth2 这是我的36机器,使用了3块网卡,每个网卡的路由配置如下
10.166.173.36 10.166.173.11 255.255.255.0 eth0
10.10.53.85 10.10.53.81 255.255.255.240 eth1
default 10.166.173.11 - - 指定“缺省路由”,其实表示3个路由中是优先级最高的1个
192.168.1.200 192.168.1.1 255.255.255.0 eth2 这是我的36机器,使用了3块网卡,每个网卡的路由配置如下
10.166.173.36 10.166.173.11 255.255.255.0 eth0
10.10.53.85 10.10.53.81 255.255.255.240 eth1
default 10.166.173.11 - - 指定“缺省路由”,其实表示3个路由中是优先级最高的1个
字段解释
192.168.1.200--->表示本地网卡ip地址(有host or subnetwork之分)
192.168.1.1--->表示网关(下一跳IP)
255.255.255.0--->表示子网掩码(subnetwork) )
eth1--->表示给哪块网卡配路由
default 10.166.173.11 - - 默认网关(缺省路由),也就是你一共配置了3个路由,缺省路由优先级最高
192.168.1.200--->表示本地网卡ip地址(有host or subnetwork之分)
192.168.1.1--->表示网关(下一跳IP)
255.255.255.0--->表示子网掩码(subnetwork) )
eth1--->表示给哪块网卡配路由
default 10.166.173.11 - - 默认网关(缺省路由),也就是你一共配置了3个路由,缺省路由优先级最高
特点:执行/etc/init.d/network restart命令让配置生效 或者 service network restart 重新加载网络配置,都要使用root用户
注意在编辑时,不要有空行,不然会出错了.
在配置文件中这样添加静态路由后,主机重启路由配置会自动加载,就不用每次手动添加路由了
注意在编辑时,不要有空行,不然会出错了.
在配置文件中这样添加静态路由后,主机重启路由配置会自动加载,就不用每次手动添加路由了
几种查看路由的命令:
(1)ip route ip与路由映射关系
10.10.53.80/28 dev eth1 proto kernel scope link src 10.10.53.85
10.166.173.0/24 dev eth0 proto kernel scope link src 10.166.173.36
192.168.1.0/24 dev eth2 proto kernel scope link src 192.168.1.200
169.254.0.0/16 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default via 10.166.173.11 dev eth0
10.166.173.0/24 dev eth0 proto kernel scope link src 10.166.173.36
192.168.1.0/24 dev eth2 proto kernel scope link src 192.168.1.200
169.254.0.0/16 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default via 10.166.173.11 dev eth0
(2)route 内核路由表
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.10.53.80 * 255.255.255.240 U 0 0 0 eth1
10.166.173.0 * 255.255.255.0 U 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth2
link-local * 255.255.0.0 U 0 0 0 eth0
loopback * 255.0.0.0 U 0 0 0 lo
default 10.166.173.11 0.0.0.0 UG 0 0 0 eth0
Destination Gateway Genmask Flags Metric Ref Use Iface
10.10.53.80 * 255.255.255.240 U 0 0 0 eth1
10.166.173.0 * 255.255.255.0 U 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth2
link-local * 255.255.0.0 U 0 0 0 eth0
loopback * 255.0.0.0 U 0 0 0 lo
default 10.166.173.11 0.0.0.0 UG 0 0 0 eth0
(3)route -n 已数字方式显示路由表
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.10.53.80 0.0.0.0 255.255.255.240 U 0 0 0 eth1
10.166.173.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.166.173.11 0.0.0.0 UG 0 0 0 eth0
Destination Gateway Genmask Flags Metric Ref Use Iface
10.10.53.80 0.0.0.0 255.255.255.240 U 0 0 0 eth1
10.166.173.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.166.173.11 0.0.0.0 UG 0 0 0 eth0
(4) netstat -rn 人性化显示路由表
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.10.53.80 0.0.0.0 255.255.255.240 U 0 0 0 eth1
10.166.173.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.166.173.11 0.0.0.0 UG 0 0 0 eth0
Destination Gateway Genmask Flags MSS Window irtt Iface
10.10.53.80 0.0.0.0 255.255.255.240 U 0 0 0 eth1
10.166.173.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.166.173.11 0.0.0.0 UG 0 0 0 eth0
实例:
数据包转发
132.0.0.0/255.0.0.0 gw set to 10.166.173.16 从这个41采集机上把发送到132.0.0.0这个网段上的数据都指向10.166.173.16地址
132.0.0.0/255.0.0.0 gw set to 10.166.173.16 从这个41采集机上把发送到132.0.0.0这个网段上的数据都指向10.166.173.16地址
添加/删除静态路由
命令方式
route add -net 10.10.54.0 netmask 255.255.255.240 gw 10.10.53.81 把发送到目的地10.10.54.0网段的数据包,先转发到10.10.53.81这个下一跳
route add -net 10.10.54.0 netmask 255.255.255.0 gw 10.10.53.81 添加路由
route add -net 10.10.54.0 netmask 255.255.255.0 gw 10.10.53.81 添加路由
route del -net 10.10.54.0 netmask 255.255.255.240 gw 10.10.53.81 把发送到目的地10.10.54.0网段的数据包,先转发到10.10.53.81这个下一跳
route del -net 10.10.54.0 netmask 255.255.255.0 gw 10.10.53.81 删除路由
route del -net 10.10.54.0 netmask 255.255.255.0 gw 10.10.53.81 删除路由
配置文件:vim /etc/sysconfig/network/routes 以#开始的行是注释,每一行是一个路由记录,由空格分隔的多列组成
<default|目的网络|目的主机> <网关> <目的网络子网掩码> <本地网络接口>
192.168.1.200 192.168.1.1 255.255.255.0 eth2
10.166.173.36 10.166.173.11 255.255.255.0 eth0
10.10.53.85 10.10.53.81 255.255.255.240 eth1
10.10.54.0 10.10.53.81 255.255.255.0 eth1
default 10.166.173.11 - -
192.168.1.200 192.168.1.1 255.255.255.0 eth2
10.166.173.36 10.166.173.11 255.255.255.0 eth0
10.10.53.85 10.10.53.81 255.255.255.240 eth1
10.10.54.0 10.10.53.81 255.255.255.0 eth1
default 10.166.173.11 - -
2012.03.19
leonarding
tianjin
Novell Suse下配置默认网关
a、在/etc/sysconfig/network/routes文件下添加如下行: 内容来自Novell迷网站
default 网关IP地址 - -
b、重启网络服务
# /etc/init.d/xinetd restart
# rcnetwork restart
c、查看路由确认生效情况
# netstat -r http://Novell.Me
相关推荐
SUSE Linux Enterprise Server 11 SP4下载,请放心使用
linux-suse11修改主机名.suse10切换到suse11用户的环境变量的问题。
SLES-11-SP4-DVD-x86_64-GM-DVD1.iso 已安装成功 suselinux 64位
linux下添加路由的方法: 一:使用 route 命令添加 使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法: //添加到主机的路由 # route add –host 192.168.168.110 dev eth0
SuSE_Linux_10.0全程教学
原积分下载地址:https://download.csdn.net/download/weixin_42350212/10468318 【付费下载之后的用户,可留言获取更多下载资源】
SUSE Linux 11 Bible
susesuse 11 sp3下载地址,官网下载太慢了,而且经常中断。
suse常用命令,日常应用的一些命令都是可以用的到的。
Suse_Linux_11_双机集群配置文档
SUSE Linux Enterprise 12 SP5-Server-DVD-x86_64-GM-DVD1.iso SUSE Linux Enterprise 12 SP5-Server-DVD-x86_64-GM-DVD2.iso Raj Meel宣布了适用于SUSE Linux Enterprise 12的第五个服务包,这是该公司商业,企业...
文件里面包含了SUSE Enterprise Linux10-15的官方系统下载地址
SUSE11G linuxSVN详细配置
SUSE.Linux.9.Bible SUSE.Linux.9.Bible SUSE.Linux.9.Bible
可以用许多不同方式安装 SUSE Linux Enterprise Server。不可能涵盖所有的引导服务器或安装服务器、自动安装或部署映像的组合。本手册应有助于为安装选择适当的部署方法。
Suse linux 11 安装手册
suse linux enterprise 11安装过程
suse linux 11 中文版安装手册
suse12sp3 & suse15