centos設置開機自啓動腳本

1.新建腳本文件

我這裏是爲了設置開機自動設置ipv6隧道,因此命名爲ipv6tunnel.shcentos

ifconfig sit0 up
ifconfig sit0 inet6 tunnel ::66.220.18.42
ifconfig sit1 up
ifconfig sit1 inet6 add 2001:470:c:8a7::2/64
route -A inet6 add ::/0 dev sit1

2.給腳本添加執行權限

chmod +x ipv6tunnel.sh

3.添加開機啓動

在/etc/rc.d/rc.local中添加剛剛的腳本(注意是全路徑的)。在centos7中,/etc/rc.d/rc.local文件的權限被下降了,開機的時候執行在本身的腳本是不能起動一些服務的,執行下面的命令能夠文件標記爲可執行的文件centos7

chmod +x /etc/rc.d/rc.local
相關文章
相關標籤/搜索