转载自http://blog.sina.com.cn/s/blog_68b156d50101kfcq.html,作者:郑大哲
部分资料摘自http://blog.chinaunix.net/uid-25513153-id-212353.html
在上一篇文章《linux下安装Quagga使电脑变成路由器》中,我们已经学会了Quagga的安装及简单配置,并且已经启动了Quagga。但是虽然我们的“路由器”(软路由)已经运行起来,但是它还无法正常工作。因为我们还没有给它配置路由表。一种方法,我们可以给它手动配置路由表,另一种方法,我们可以运行一些路由协议(如rip,ospf),实现自动配置。先简单介绍一下手动配置的方法。
手动配置路由表
首先启动Quagga的守护进程,
利用telnet进入zebra配置
zinkin@zinkin-desktop:~/quagga/quagga-0.99.17$ telnet localhost 2601
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hello, this is Quagga (version 0.99.17).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
User Access Verification
Password:(输入
zebra)
Router> en
Password:(输入
zebra)
Router#
show in
Interface eth0 is up, line protocol detection is disabled
index 2 metric 1 mtu 1500
flags:
HWaddr: 48:5b:39:b8:f9:4f
inet 218.192.169.88/24 broadcast 218.192.169.255
inet6 2001:250:3000:4bf3:4a5b:39ff:feb8:f94f/64
inet6 fe80::4a5b:39ff:feb8:f94f/64
Interface lo is up, line protocol detection is disabled
index 1 metric 1 mtu 16436
flags:
inet 127.0.0.1/8
inet6 ::1/128
Router#
show interface
Interface
eth0 is up, line protocol detection is disabled
index 2 metric 1 mtu 1500
flags:
HWaddr: 48:5b:39:b8:f9:4f
inet 218.192.169.88/24 broadcast 218.192.169.255
inet6 2001:250:3000:4bf3:4a5b:39ff:feb8:f94f/64
inet6 fe80::4a5b:39ff:feb8:f94f/64
Interface lo is up, line protocol detection is disabled
index 1 metric 1 mtu 16436
flags:
inet 127.0.0.1/8
inet6 ::1/128
Router#
Router#:conf t进入配置模式
Router(config)#
interface eth0 (进入接口f0/0)
Router(config-if)#
ip address 192.168.1.1/24 (设置接口ip地址和子网掩码)
Router(config-if)#
no shutdown (启用接口)
开启RIP协议
对于结构比较简单的网络来说,手动配置路由的方法是可行的,但是对于具有一定规模的网络来说,就应该使用自动配置的方法了,同时,自动配置还能在网络结构出现变化的情况下及时自动反应,避免在我们搂着小姑娘的时候还老板叫去维护网络。
RIP协议的配置文件默认存放在/usr/local/etc/下,执行以下命令
- #cp /usr/local/etc/ripd.conf.sample /usr/local/etc/ripd.conf
- #vi /usr/local/etc/ripd.conf
加入如下内容
- router rip
- version 2
- network eth0
- network eth1
rip正常启动后,可以用ip route show看看路由是否已经建立。