我有一台带有 2 个 NIC 的 Linux 机器,其中一台上设置了我的桥接调制解调器的公共 IP
另一个具有本地局域网
enp7s0 的设备:WAN IP
enp6s0:192.168.0.1
我设置了 iptables 规则,但它似乎不起作用。ip
转发已激活,但它无法完成我想要完成的操作。
以下是我的规则:
# Generated by iptables-save v1.6.1 on Mon Oct 7 00:10:54 2019
*mangle
:PREROUTING ACCEPT [92:10575]
:INPUT ACCEPT [72:9227]
:FORWARD ACCEPT [20:1348]
:OUTPUT ACCEPT [77:8645]
:POSTROUTING ACCEPT [97:9993]
COMMIT
# Completed on Mon Oct 7 00:10:54 2019
# Generated by iptables-save v1.6.1 on Mon Oct 7 00:10:54 2019
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [77:8645]
-A INPUT -i lo -j ACCEPT
-A INPUT -i enp6s0 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i enp7s0 -p udp -m udp --dport 5080 -m string --string
"sipcli" --algo bm --to 65535 -j DROP
-A INPUT -i enp7s0 -p udp -m udp --dport 5080 -m string --string
"friendly-scanner" --algo bm --to 65535 -j DROP
-A INPUT -i enp7s0 -p udp -m udp --dport 5080 -m string --string
"VaxSIPUserAgent" --algo bm --to 65535 -j DROP
-A INPUT -i enp7s0 -j DROP
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i enp6s0 -o enp7s0 -j ACCEPT
-A FORWARD -i enp7s0 -o enp6s0 -j ACCEPT
COMMIT
# Completed on Mon Oct 7 00:10:54 2019
# Generated by iptables-save v1.6.1 on Mon Oct 7 00:10:54 2019
*nat
:PREROUTING ACCEPT [11:741]
:INPUT ACCEPT [11:741]
:OUTPUT ACCEPT [2:120]
:POSTROUTING ACCEPT [2:120]
-A PREROUTING -i enp7s0 -p udp -m udp --dport 10000:20000 -j DNAT --
to-destination 192.168.0.1
-A PREROUTING -i enp7s0 -p udp -m udp --dport 5060 -j DNAT --to-
destination 192.168.0.1
-A PREROUTING -i enp7s0 -p udp -m udp --dport 5061 -j DNAT --to-
destination 192.168.0.1
-A POSTROUTING -o enp6s0 -j MASQUERADE
COMMIT
# Completed on Mon Oct 7 00:10:54 2019
如果你们当中有人知道我做错了什么……谢谢。
最好的,驯兽师
答案1
您是否启用了 IP 转发?..总是让我
检查一下:
# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
设置方法:
# sysctl net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1