|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!明天在主动化安装剧本时必要防火墙设置文件开放3306端口
sed-i
在含有特定字符串的行前拔出新行
sed-i/特定字符串/i新行字符串
例:
[root@www~]#vi/etc/sysconfig/iptables
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT
#Firewallconfigurationwrittenbysystem-config-securitylevel
#Manualcustomizationofthisfileisnotrecommended.
*filter
:INPUTACCEPT[0:0]
:FORWARDACCEPT[0:0]
:OUTPUTACCEPT[0:0]
:RH-Firewall-1-INPUT-[0:0]
-AINPUT-jRH-Firewall-1-INPUT
-AFORWARD-jRH-Firewall-1-INPUT
-ARH-Firewall-1-INPUT-ilo-jACCEPT
#Uncommentlinebelowifyouhave2NICsandeth1ispublic
#-ARH-Firewall-1-INPUT-ieth0-jACCEPT
-ARH-Firewall-1-INPUT-picmp--icmp-typeany-jACCEPT
-ARH-Firewall-1-INPUT-p50-jACCEPT
-ARH-Firewall-1-INPUT-p51-jACCEPT
-ARH-Firewall-1-INPUT-pudp--dport5353-d224.0.0.251-jACCEPT
-ARH-Firewall-1-INPUT-pudp-mudp--dport631-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateESTABLISHED,RELATED-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport5060-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport4569-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport21-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport443-jACCEPT
#-ARH-Firewall-1-INPUT-mtcp-ptcp--dport3306-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport10000-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport10000:65000-jACCEPT
-ARH-Firewall-1-INPUT-jREJECT--reject-withicmp-host-prohibited
COMMIT
实行:
sed-i/-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT/i-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT/etc/sysconfig/iptables
[root@www~]#vi/etc/sysconfig/iptables
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT
#Firewallconfigurationwrittenbysystem-config-securitylevel
#Manualcustomizationofthisfileisnotrecommended.
*filter
:INPUTACCEPT[0:0]
:FORWARDACCEPT[0:0]
:OUTPUTACCEPT[0:0]
:RH-Firewall-1-INPUT-[0:0]
-AINPUT-jRH-Firewall-1-INPUT
-AFORWARD-jRH-Firewall-1-INPUT
-ARH-Firewall-1-INPUT-ilo-jACCEPT
#Uncommentlinebelowifyouhave2NICsandeth1ispublic
#-ARH-Firewall-1-INPUT-ieth0-jACCEPT
-ARH-Firewall-1-INPUT-picmp--icmp-typeany-jACCEPT
-ARH-Firewall-1-INPUT-p50-jACCEPT
-ARH-Firewall-1-INPUT-p51-jACCEPT
-ARH-Firewall-1-INPUT-pudp--dport5353-d224.0.0.251-jACCEPT
-ARH-Firewall-1-INPUT-pudp-mudp--dport631-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateESTABLISHED,RELATED-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport5060-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport4569-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport21-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport443-jACCEPT
#-ARH-Firewall-1-INPUT-mtcp-ptcp--dport3306-jACCEPT
-ARH-Firewall-1-INPUT-mstate--stateNEW-mtcp-ptcp--dport10000-jACCEPT
-ARH-Firewall-1-INPUT-mudp-pudp--dport10000:65000-jACCEPT
-ARH-Firewall-1-INPUT-jREJECT--reject-withicmp-host-prohibited
COMMIT
欢迎大家来到仓酷云论坛! |
|