本文属原创,写得不好之处还请高手们指正,Linux下的动态路由对于本人相当有意义的,它可以避免很多不必要的操作,现在来回忆一下本人安装设置的过程。
首先要找到相关的软件,类似的有很多,本人选择了zebra。安装此软件,常规方法:rpm -ivh zebra*.rpm
基于ospf的设置
#cd /etc/zebra
#touch ospdf.conf
#/etc/rc.d/init.d/zebra start 启动zebra这个服务
#/etc/rc.d/init.d/ospfd start 启动ospfd
好了,现在可以登陆路由
#vtysh
如果按”?”键列出的内容,可以查看相关命令。
键入"enable" 进入超级模式,此时提示符的 ">" 会变成 "#"
#configure terminal 现在进入配置模式
提示会变成类似 localhost(config)# ,就表示进入了配置模式了。
输入命令:interface eth0
提示会变成类似 localhost(config-if)#
现在就可以配置第一张网卡了,
localhost(config-if)# ip address 192.168.1.166/24
(默认此网卡是死的,需要手动激活才能使用)
localhost(config-if)# no shutdown #这就是激活了。
localhost(config-if)# exit #推出eth0的设置
配置第二张网卡
localhost(config)# interface eth1
localhost(config-if)# ipadress 192.168.4.4/24
localhost(config-if)# no shutdown
localhost(config-if)# exit
接着就是配置协议
localhost(config)# router ospf
显示“localhost(config-router)# ” 接着输入命令
localhost(config-router)# network 192.168.1.0/24 area 1
localhost(config-router)# network 192.168.4.0/24 area 1
以上是指定区域为 “1”区
localhost(config-router)# end
结束配置
然后复制一个文件
localhost(config)# copy running-config startup-config
查看路由的信息可以使用:show running-config
显示路由器学习路由知识情况用:show ip route
好了,这样就完成1和4 网段之间的动态路由了,如有更多网段,则在配置网卡的步骤中多
添加几个相似的设置就可以了。
下面是基于rip的设置:
几乎所有步骤都相同
#cd /etc/zebra
#touch ripd.conf
#/etc/rc.d/init.d/zebra start 启动zebra这个服务
#/etc/rc.d/init.d/ripd start 启动ospfd
好了,现在可以登陆路由
#vtysh
输入命令:interface eth0
现在配置第一张网卡
localhost(config-if)# ip address 192.168.1.166/24
localhost(config-if)# no shutdown
localhost(config-if)# exit
配置第二张网卡
localhost(config)# interface eth1
localhost(config-if)# ipadress 192.168.4.4/24
localhost(config-if)# no shutdown
localhost(config-if)# exit
配置协议
localhost(config)# router rip
localhost(config-router)# network 192.168.1.0/24
localhost(config-router)# network 192.168.4.0/24
localhost(config-router)# version 2
localhost(config-router)# end
结束配置
然后复制一个文件
localhost(config)# copy running-config startup-config
查看路由的信息可以使用:show running-config
显示路由器学习路由知识情况用:show ip route