当前位置:网站首页>Debian 10 iptables (防火墙)配置
Debian 10 iptables (防火墙)配置
2022-07-31 05:19:00 【活加梦】
目录
一、题目要求
IPTABLES (IspSrv)
- 修改 INPUT 和 FORWARD 链默认规则为 DROP,添加必要的放行规则,在确保安全 的前提下,最小限度放行流量通信;
- 放行 ICMP 流量;
二、 配置过程
IspSrv
1.下载iptables防火墙服务
[email protected]:~# apt -y install iptables-persistent
2.修改 INPUT 和 FORWARD 链默认规则为DROP
[email protected]:~# iptables -P INPUT DROP #INPUT链拒绝所有流量进入
[email protected]:~# iptables -P FORWARD DROP #FORWARD链拒绝所有流量转发
[email protected]:~# netfilter-persistent save #保存进配置文件
3.放行icmp流量
[email protected]:~# iptables -A INPUT -p icmp -j ACCEPT #放行进站的icmp流量
[email protected]:~# iptables -A OUTPUT -p icmp -j ACCEPT #放行出站的icmp流量
[email protected]:~# netfilter-persistent save #将规则保存进配置文件
添加必要的放行规则,在确保安全 的前提下,最小限度放行流量通信;(在后面题目中会慢慢完善)
三 、测试截图与评分要点
测试:IspSrv
评分要点:
四、扩展内容
删除规则
iptables -D FORWARD(INPUT/OUTPUT) 1
iptables -t nat -D POSTROUTING (INPUT/PREROUTING) 2
允许icmp通过
iptables -A INPUT -p icmp -j ACCEPT #放行所有IP的入站icmp流量
iptables -A OUTPUT -p icmp -j ACCEPT #放行所有IP的入站icmp流量
iptables -A FORWARD -p icmp -j ACCEPT #如果是作为网关路由器要放开转发的icmp流量
NAT转换规则
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o ens38 -j MASQUERADE # -s 表示哪些网段需要nat转换,-o 表示用那个网卡出去外网。
允许DNS解析(自己访问外网DNS服务器)
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
允许别人访问本身的DNS(自己是DNS服务器)
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --sport 53 -j ACCEPT
网关防火墙上(流量都是从你这台服务器上出去)
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
iptables -A FORWAD -p udp --sport 53 -j ACCEPT
将dns 53 端口映射到100的服务器上(网关服务器)
iptables -t nat -A PREROUTING -d 81.6.63.254 -p tcp --dport 53 -j DNAT --to-destination 192.168.100.100
#将去往81.6.63.254 目的是tcp的53端口映射到192.168.100.100的tcp的53端口
iptables -t nat -A PREROUTING -d 81.6.63.254 -p udp --dport 53 -j DNAT --to-destination 192.168.100.100
#将去往81.6.63.254 目的是udp的53端口映射到192.168.100.100的udp的53端口
允许dhcp发放地址(dhcp服务器)
iptables -A INPUT -p udp --dport 67 -j ACCEPT #客户端从68号端口发 服务端从67端口收
允许来着客户端同步ntp服务器(服务器)
iptables -A INPUT -p udp --dport 123 -j ACCEPT
iptables -A INPUT -p udp --sport 123 -j ACCEPT
允许同步ntp服务器(客户端)
iptables -A INPUT -p udp --sport 123 -j ACCEPT
iptables -A OUTPUT -p upd --dport 123 -j ACCEPT
路由防火墙
iptables -A FORWAD -p udp --dport 123 -j ACCEPT
服务器访网页允许被访问
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
客户端访问网页
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A OOUTPUT -p tcp --dport 80 -j ACCEPT
路由器防火墙写入
iptables -A FORWAD -p tcp --dport 80 -j ACCEPT
iptables -A FORWAD -p tcp --sport 80 -j ACCEPT
允许从dns服务器向主服务器同步dns
iptables -A INPUT -p tcp --sport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
允许主dns服务器给从服务器同步dns
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 53 -j ACCEPT
允许主从dns同步(网关服务器)
iptables -A FORWARD -p tcp --dport 53 -j ACCEPT
iptables -A FORWAD -p tcp --sport 53 -j ACCEPT
边栏推荐
猜你喜欢
小型网站组建(ENSP)
Four common ways of POST to submit data
Pytorch study notes 7 - processing input of multi-dimensional features
ES6-03-解构赋值
vs2022 xlua 集成第三方库编译报错Generator Visual Studio 15 2017 could not find any instance of Visual Studio.
网盘程序 ZFile安装
Unity转微信小游戏与JS交互
911崩了,自养号测评环境IP有哪些更好的选择
【博学谷学习记录】超强总结,用心分享 | 软件测试 抓包
力扣151. 颠倒字符串中的单词
随机推荐
Detailed explanation of mysql transaction principle
DOM操作-案例:切换背景图片
Learning and understanding of ROS service programming
随机数,函数
ES6-03-解构赋值
CSDN上markdown编写的一些便捷操作
UR3机器人雅克比矩阵
哈希表基础
ROS subscription to multiple topics time synchronization problem
nacos1.4.1创建配置报错
VNC 启动脚本
The solution to the IDEA console not being able to enter information
数据库/表的基本操作
ES6-Map和Set
力扣刷题.快乐数
等待,信息打印,浏览器操作,键盘事件
软件测试之登录测试详解
测试CSDN积分需求
Incredibuild 宣布支持 Yocto
MySQL表的增删改查(1)