时光如水,总是无言。若你安好,便是晴天。

eve-ng ubuntu 20.04 设置iptables

一、设置方法

1、建立iptables规则开机加载脚本

sudo vi /etc/network/if-pre-up.d/iptablesload
写入以下内容
#!/bin/bash
iptables-restore < /etc/iptables.rules
exit 0
在这里插入图片描述

2、建立iptables规则关机/重启保存脚本

sudo vi /etc/network/if-post-down.d/iptablessave
写入以下内容
#!/bin/bash
iptables-save > /etc/iptables.rules
exit 0
在这里插入图片描述

3、添加可执行权限

chmod u+x /etc/network/if-pre-up.d/iptablesload
chmod u+x /etc/network/if-post-down.d/iptablessave

4、保存当前iptables规则到配置文件

sudo iptables-save > /etc/iptables.rules

二、命令解释

执行脚本加入到网卡up down自动执行脚本的目录中,在网卡up前加载iptables规则配置文件,在网卡down后保存当前iptables规则到iptables规则配置文件。
在这里插入图片描述

posted @ 2022-12-11 15:34  OceanWaves  阅读(209)  评论(0)    收藏  举报  来源
/* 看板娘 */ /* 粒子吸附*/