linux - 从 AS 生成 ipset 表

标签 linux networking firewall iptables

我需要生成 ipset 表,其中包含分配给特定 AS (ASN) 编号的所有 (ipv4) 子网。 你知道任何 Linux 工具吗?

谢谢。

最佳答案

完成:

#!/bin/bash

# define AS to block
as=( AS1111
AS2222
)

# define output
output=('create block hash:net family inet hashsize 1024 maxelem 1024')

# build list of subnets
for i in "${as[@]}"
do
        echo $i
        output+=(`whois -h whois.radb.net -- "-i origin $i" | grep -Eo "([0-9.]+){4}/[0-9]+" | head`)
done

# dump output to file
printf '%s\n' "${output[@]}" > /etc/sysconfig/ipset

exit 0

关于linux - 从 AS 生成 ipset 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40818424/

相关文章:

linux - Bash 脚本没有产生预期的结果

python - 如何在 Python 字典中转换包含以下输出的表?

linux - 添加链接本地地址

python - 从另一个区域连接到 DocumentDB

linux - 将一个命令的输出重定向到与其余脚本不同的文件

linux - 无法将包添加到 Buildroot

c - 在 Linux 上用 C 语言处理超过 1024 个文件描述符

c++ - 操作系统何时关闭已连接的 UDP 套接字?

networking - FileZilla - 检索目录列表时出现 "The data connection could not be established: ECONNREFUSED - Connection refused by server"

algorithm - 中间盒遍历的安全成本