首页 > 系统相关 >linux根据地址添加出站策略--脚本

linux根据地址添加出站策略--脚本

时间:2023-08-03 10:14:30浏览次数:40  
标签:xml -- direct echo num 出站 linux policy

文件名称:add_policy.sh

内容:

#!/bin/bash

main(){
  num=1
  echo "<?xml version="1.0" encoding="utf-8"?>
<direct>
</direct>
" > direct.xml
#  read -p "请输入文件全路径名称:" ip_addr
  while read line
  do 
    policy="<rule priority=$num table="filter" ipv="ipv4" chain="OUTPUT">-d $line -j ACCEPT</rule>"
    echo $policy
    sed -i "/<\/direct>/i ${policy}" direct.xml
    num=$(( $num + 1 ))
  done < $1
}

if [ $(echo $#) = 1 ]
then 
  main $1
else
  echo "使用方法add_policy 跟上文件:address.txt"
fi

 

标签:xml,--,direct,echo,num,出站,linux,policy
From: https://www.cnblogs.com/yeziwinone/p/17602498.html

相关文章

  • Java Word转为PNG
    主要代码逻辑//判断生成路径FilefileDir=newFile("./generatePng");if(!fileDir.exists()){fileDir.mkdirs();}StringworkPermitId=唯一标识;Documentdoc=newDocument(word文档路径);if(doc.getPageCount()>1){//多张for(inti=0;i<doc.......
  • 养鸡场损失背后,是通讯故障还是数据大危机
     近日,一场特殊的案件完成了判决,由于设备发生通信故障导致风机停止工作,进而导致1466只养殖的蛋鸡死亡,造成了巨额财产损失。最终,提供物联网终端设备的神桥公司被判处承担农场的70%的赔偿责任。虽然被答辩人未公开表示是否会继续上诉,但该判决结果在二审法院中并未获得支持,但这起......
  • Statement.executeQuery() cannot issue statements that do not produce result sets
    在用SpringBootJPA的时候导致Statement.executeQuery()cannotissuestatementsthatdonotproduceresultsets解决方法:在@Query上加上@Modifying,表示不需要返回值@Query对应到底层jdbc框架是Statement.executeQuery(),而@Modifying@Query对应的是Statement.execute();......
  • gitlab 报错error: 20667 bytes of body are still expectedB fatal: early EOF
    报错如下:C:\Users\meiktv\StudioProjects\meiktv_android_vod_3>gitclonehttps://gitlab.meiktv.com/client/meiktv_android_vod.gitCloninginto'meiktv_android_vod'...remote:Enumeratingobjects:46631,done.remote:Countingobjects:100%(26......
  • 魔刀千刃(轮廓)
    #include<iostream>#include"minecraft.h"usingnamespacestd;TxMinecraftmc;intmain(){boolc=true;c=mc.ConnectMinecraft("zk","badaa4c2a1b546f1868517667456b050");if(!c){cout<<"连接失败"<<endl;return0......
  • 20230803
    数论#include<bits/stdc++.h>usingnamespacestd;constintMOD=100003;longlongf(longlonga,longlongb){longlongx=1,y=a;while(b>=1){if(b%2==1){x=x*y%MOD;}y=y*......
  • 题解 SP15454
    前言数学符号约定\(\operatorname{lowbit}(x)\):表示\(x\)的二进制最低位。\([a,b]\):表示区间\(a\simb\),其中包含\(a,\,b\)端点,其区间长度为\(b-a+1\)。如非特殊说明,将会按照上述约定书写符号。题目大意有一个初始全为\(0\)的序列\(A\),你需要支持一下操作:add......
  • 阿里面试
    1、Linux系统方面1)进程和线程的区别(不能太书面化)(需要从内存角度,或者其他角度描述)需要用自己理解的方式去回答这个问题,如果你回答了xxx是基本单位,这样子是不行的。技术面试会追问你,需要你用自己的话去理解进程和线程。线程和进程是否是独立的?线程和进程的之间内存空间是否是共享......
  • vue中展示多张小图轮播每几秒走一张,支持左右点击
    html部分    <divclass="regional-services-list"style="overflow:hidden;"@mouseenter="stopCar()"@mouseleave="starCar()">     <divclass="preIcon"@click="preChange()"><......
  • frp 树莓派通过systemd设置开机启动
    树莓派操作系统为xxx@raspberrypi:$cat/etc/os-releasePRETTY_NAME="DebianGNU/Linux11(bullseye)"NAME="DebianGNU/Linux"VERSION_ID="11"VERSION="11(bullseye)"VERSION_CODENAME=bullseyeID=debianHOME_URL="https:......