Small Korean Writing Shell - Following Iptables (automatically release and block ip or port through script)

Scene reconstruction:

Xiaoyue: Hey, the team leader must manually write firewall rules every time he configures a server!

Xiaohan: Then write it manually.

Xiaoyue: Your script is so good, can you write a script to selectively block ip and port?

Xiao Han: I will write you one when I am free.

Three days later ...

Xiaohan: The script is sent to you. You can try it on the test environment!

 

 

 

Guess every day:

Hehe and Haha are good friends. One day Haha died. Hehe went to the grave. What did Hehe say in front of the tomb? (Tell me in the comment area)

 

 

 

Core code area

[root@hya shell]# vim iptables_zs.sh
#!/bin/bash
echo_caidan() {
# 清空防火墙规则
read -ep "是否清空防火墙规则(y/n):" name
if [ $name == y ];then
        iptables -F
        echo "
        1) 放行端口
        2) 封锁端口
        3) 放行

Guess you like

Origin blog.csdn.net/yeyslspi59/article/details/108651094