Linux防火墙.md

场景用例

禁止公网访问、不限制局域网访问和进流量

1
2
3
4
5
6
7
8
9
10
11
# 用例局域网为 192.168.122.0/24
# 直接用 sudo iptables -P OUTPUT DROP 会把被访问连接也断开

[root@localhost ~]# sudo iptables -P INPUT ACCEPT
[root@localhost ~]# sudo iptables -P FORWARD ACCEPT
[root@localhost ~]# sudo iptables -P OUTPUT ACCEPT
[root@localhost ~]# sudo iptables -A INPUT -s 192.168.122.0/24 -j ACCEPT
[root@localhost ~]# sudo iptables -A OUTPUT -d 192.168.122.0/24 -j ACCEPT
[root@localhost ~]# sudo iptables -A OUTPUT ! -d 192.168.122.0/24 -j DROP

# iptables -D 是删除策略

Linux防火墙.md
https://abrance.github.io/2024/01/18/domain/linux/Linux防火墙/
Author
xiaoy
Posted on
January 18, 2024
Licensed under