初见shell,设置端口参数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了初见shell,设置端口参数相关的知识,希望对你有一定的参考价值。

其实我是故意不写删除的部分的,因为管理的服务器只会加端口不会关。


=====================

#!bin/bash
while :
do

clear
echo "Detect open ports:"
echo -e "\033[33m`cat /etc/sysconfig/iptables | grep "dport" | cut -d ‘ ‘ -f 12`\033[0m"
echo "---------------------"
echo "Plase enter new port(Ctrl+c to Exit):"
read inport
#echo "---------------------"
#echo "Enter to Finish,Ctrl+c to Exit."
ilink=`grep -n "dport" /etc/sysconfig/iptables | tail -1 | cut -d ‘:‘ -f 1 `
#echo $ilink
#((ilink++))
t1="-A INPUT -m state --state NEW -m tcp -p tcp --dport"
t2="-j ACCEPT"
sed -i "${ilink}a ${t1} ${inport} ${t2}" /etc/sysconfig/iptables

done


===================================


后记:有空整理整理应该能够更合理一点,不过目前理解的就这么多了。

以上是关于初见shell,设置端口参数的主要内容,如果未能解决你的问题,请参考以下文章

初见shell,设置SElinux参数

python粘结shell监听端口设置

python粘结shell监听端口设置

Linux命令-nc(端口监控文件传输反弹shell等)

shell 查看目前机器listen的所有端口

linux shell命令行向udp端口发送数据