编写配置脚本(符合chkconfig规范)[root@hunterfu ~]# cat /etc/init.d/config_tap
#!/bin/bash
#
# config_tap Start up the tun/tap virtual nic
#
# chkconfig: 2345 55 25
USER="root"
TAP_NETWORK="192.168.0.1"
TAP_DEV_NUM=0
DESC="TAP config"
do_start() {
if [ ! -x /usr/sbin/tunctl ]; then
echo "/usr/sbin/tunctl was NOT found!"
exit 1
fi
tunctl -t tap$TAP_DEV_NUM -u root
ifconfig tap$TAP_DEV_NUM ${TAP_NETWORK} netmask 255.255.255.0 promisc
ifconfig tap$TAP_DEV_NUM
}
do_stop() {
ifconfig tap$TAP_DEV_NUM down
}
do_restart() {
do_stop
do_start
}
check_status() {
ifconfig tap$TAP_DEV_NUM
}
case $1 in
start) do_start;;
stop) do_stop;;
restart) do_restart;;
status)
echo "Status of $DESC: "
check_status
exit "$?"
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac可以根据具体需求修改此脚本