您现在的位置是:网站首页> 编程资料编程资料
Linux iptables的备份和恢复操作详解_LINUX_操作系统_
2024-01-24
108人已围观
简介 Linux iptables的备份和恢复操作详解_LINUX_操作系统_
1、iptables的配置文件位置:/etc/sysconfig/iptables
主控机:即业务运行中的机子;备份机:即主控机故障时,切换到备份的机子
--在主控机上的操作-------------------
2、建立目录:
mkdir /root/script/
3、在/root/script/目录下建立脚本:
cp /etc/sysconfig/iptables /bak/iptables/iptables_$(date +%Y%m%d%H)
4、定制自动任务:
*/10 * * * * /usr/sbin/ntpdate 210.72.145.44
10 * * * * sh /root/script/backup.sh
--在备份机上操作---------------------
5、建立目录:
mkdir /root/script/
6、在/root/script/目录下建立脚本:
#!/usr/bin/expect -f
set password gst
spawn scp -P 22 root@202.105.135.52:/etc/sysconfig/iptables /bak/iptables/lt/iptables
set timeout 300
expect "root@202.105.135.52's password:"
set timeout 300
send "$passwordr"
set timeout 300
send "exitr"
expect eof
7、在/root/script/目录下建立脚本:
#!/usr/bin/expect -f
set password gst
spawn scp -P 22 root@183.62.178.91:/etc/sysconfig/iptables /bak/iptables/yd/iptables
set timeout 300
expect "root@183.62.178.91's password:"
set timeout 300
send "$passwordr"
set timeout 300
send "exitr"
expect eof
8、在/root/script/目录下建立脚本:
expect /root/script/scp_lt.sh
expect /root/script/scp_yd.sh
sed -i 's/202.105.135.52/183.62.178.85/g' /bak/iptables/lt/iptables
sed -i 's/58.251.49.18/58.250.56.154/g' /bak/iptables/lt/iptables
cp /bak/iptables/lt/iptables /etc/sysconfig/iptables
/etc/init.d/iptables restart
/etc/init.d/iptables save
mv /bak/iptables/lt/iptables /bak/iptables/lt/iptables_$(date +%Y%m%d%H)
mv /bak/iptables/yd/iptables /bak/iptables/yd/iptables_$(date +%Y%m%d%H)
9、注意,要在备份机上手动远程登陆一次,以获得RSA的公钥,之后就不用这样登陆了,否则脚本会执行错误
10、定制自动任务:
*/10 * * * * /usr/sbin/ntpdate 210.72.145.44
20 * * * * sh /root/script/backup.sh
相关内容
- 刀塔传奇骨弓橙色二阶装备分析_手机游戏_游戏攻略_
- 全民斩将坐骑怎么升阶 全民斩将坐骑系统培养和升阶玩法攻略_手机游戏_游戏攻略_
- 我叫MT2英雄碎片100%掉落方法介绍_手机游戏_游戏攻略_
- 我叫MT2傻馒、劣人和方砖哪个好_技能对比解析_手机游戏_游戏攻略_
- 天天酷跑和风小鹿萌装技能是什么 和风小鹿萌装技能详细介绍_手机游戏_游戏攻略_
- 我叫MT2圣诞新版本最新玩法详解_手机游戏_游戏攻略_
- 我叫MT2全新竞技场阵容 无脑针对双治疗组合_手机游戏_游戏攻略_
- 天下HD任务攻略_天下HD任务怎么完成_手机游戏_游戏攻略_
- 我叫MT2菜刀队怎么搭配_我叫MT2竞技场菜刀队阵容搭配推荐_手机游戏_游戏攻略_
- 炉石传说盗贼机械卡组分享 低成本机械海盗贼套牌_手机游戏_游戏攻略_
