centos设置开机自启动脚本

1.新建脚本文件

我这里是为了设置开机自动设置ipv6隧道,所以命名为ipv6tunnel.sh

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文件的权限被降低了,开机的时候执行在自己的脚本是不能起动一些服务的,执行下面的命令可以文件标记为可执行的文件

chmod +x /etc/rc.d/rc.local

猜你喜欢

转载自www.cnblogs.com/roadwide/p/11266752.html
今日推荐