#!/bin/bash
yum install -y readline-devel.x86_64 texinfo.x86_64
cd /tmp/
tar -xf quagga-1.1.1.tar.gz -C /opt/
cd /opt/quagga-1.1.1
mkdir -p /var/run/quagga
./configure --prefix=/usr/local/quagga --enable-vtysh --localstatedir=/var/run/quagga --sysconfdir=/etc/quagga
if [ $? -eq 0 ];then make && make install;else echo ERROR;exit 2; fi
ldconfig
ln -sf /usr/local/quagga/bin/vtysh /sbin/
cp /etc/quagga/ospfd.conf.sample /etc/quagga/ospfd.conf
cp /etc/quagga/zebra.conf.sample /etc/quagga/zebra.conf
cp /etc/quagga/vtysh.conf.sample /etc/quagga/vtysh.conf
chown root -R /var/run/quagga/
#写入开机启动
cat >>/etc/init.d/quagga << ‘EOF‘
#!/bin/bash
# chkconfig: - 85 15
# description: lu SOPF server. It is used to swarm-server
EXEC_DIR=/usr/local/quagga/sbin
CONF_DIR=/etc/quagga
LIB_DIR=/usr/local/quagga/lib
PID_DIR=/var/run/quagga
DAEMON=(zebra ospfd )
USER=root
TIME_DELAY=2
#DAEMON=(zebra ospfd ospf6d ripd bgpd)
#set librery path
export LD_LIBRARY_PATH=$LIB_DIR:$LD_LIBRARY_PATH
#
echo make sure user \"$USER\" has read-write privileges in directory \"$PID_DIR\" !
if [ ! -d $PID_DIR ]
then
mkdir -p $PID_DIR
chown -R $USER $PID_DIR
fi
start()
{
for d in ${DAEMON[*]}; do
$EXEC_DIR/$d -f $CONF_DIR/$d.conf -i $PID_DIR/$d.pid -u $USER -g $USER -d
ps -ef | grep $d
if [ $d = "zebra" ] ; then
sleep $TIME_DELAY
fi
done
echo "start (${DAEMON[*]}) finished!"
}
stop()
{
for d in ${DAEMON[*]}; do
killall $d
#rm -f $PID_DIR/$d.pid
done
rm -f $PID_DIR/*
echo "stop (${DAEMON[*]}) finished!"
}
case $1 in
start)
start ;;
stop)
stop ;;
restart)
stop
start ;;
*)
echo "Usage: $0 start | stop | restart"
esac
ps -ef|grep --color quagga
EOF
echo "/etc/init.d/quagga start" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
chmod +x /etc/init.d/quagga
chkconfig --add quagga
chkconfig --level 345 quagga on
service quagga start
route -n
问题解决
i) 如果遇到zebra库文件未找到错误,则到目录 /etc/ld.so.conf.d下面新建个文件,
内容为quagga安装的库路径,例如: /usr/local/lib
然后 sudo ldconfig即可。
ii) 如果不能连接vtysh的话,是因为在/var/run/quagga/*.vty文件对当前执行vtysh命令的用户没有权限。
可以使用: sudo /usr/local/bin/vtysh即可。
也可以: sudo chmod 777 /var/run/quagga/* ,(当zebra都启动之后), 然后运行vtysh即可。
iii) 如果需要设置IP地址,设置路由等,则建议使用root用户身份运行Quagga(zebra/ospfd/bgpd等), 否则修改路由IP等会导致没有权限的错误。
iii) 如果路由不能转发,修改/etc/sysctl.conf文件。 启用IPv4转发功能
net.ipv4.ip_forward = 1
iv) 如果发生了源路由验证的路由问题, 修改/etc/sysctl.conf文件。 禁用源路由验证功能
net.ipv4.conf.default.rp_filter = 1
v) 如果要启用net-snmp支持,则如下:
#sudo yum install net-snmp net-snmp-devel net-snmp-perl net-snmp-utils
# ./configure --enable-vtysh --localstatedir=/var/run/quagga --sysconfdir=/etc/quagga --enable-snmp=smux
原文地址:http://10941585.blog.51cto.com/10931585/1919965