我需要在UFW中实现以下规则,但不知道如何做到这一点:
iptables -t nat -A POSTROUTING -o eth0 -s 10.8.0.0/24 -j MASQUERADE
#Note: If you use tcp protocol you must change -p udp to -p tcp and --ddport 1194 to --ddport 443
iptables -A INPUT -i eth0 -p udp --dport 1194 -j ACCEPT
iptables -A INPUT -i tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o eth0 -s 10.8.0.0/24 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
#Note: If you use tcp protocol you must change -p udp to -p tcp and --ddport 1194 to --ddport 443
ip6tables -A INPUT -i eth0 -p udp --dport 1194 -j ACCEPT
ip6tables -A INPUT -i tun0 -j ACCEPT
ip6tables -A FORWARD -i tun0 -o eth0 -s 2a01:4f8:c2c:5fc7:80::/112 -m state --state NEW -j ACCEPT我怎么才能正确地做这件事?
谢谢你。
发布于 2021-05-06 10:02:10
与其逐字复制现有的规则,不如学习使用UFW框架来达到预期的效果。
开放特定端口将在man ufw中解释
在手册man ufw-framework中解释了设置NAT和IP伪装,并要求:
IP伪装,允许eth1上10.0.0.0/8网络的计算机共享eth0上的单个IP地址:编辑
/etc/ufw/sysctl.confto for : net.ipv4.ip_forward=1添加到/etc/ufw/before.rules的末尾:*nat :POSTROUTING接受-A POSTROUTING -s 10.0.0.0/8 -o eth0 -j伪装提交
对于一些更复杂的场景,UFW框架还没有提供一个好的解决方案,对于那些用例,它支持加载“原始”iptables规则。
https://serverfault.com/questions/1062641
复制相似问题