OpenVPN + iptables - 定義有效路由

OpenVPN + iptables - 定義有效路由

我有一個bastion透過 OpenVPN 接受用戶的伺服器。堡壘有兩個網路適配器:一個連接互聯網,另一個連接專用網路。每個使用者都有不同的IP位址和他可以存取專用網路內部的不同位置。

例如:使用者 John10.8.0.1在 OpenVPN 上擁有靜態 IP。 John 只能10.8.1.1在內網內部存取該 IP 位址。約翰嘗試訪問的任何其他地方都應該被阻止。

我嘗試做這樣的事情:

iptables -A FORWARD -p tcp --source 10.8.0.1 --destination 10.8.1.1 -j ACCEPT

INPUT、OUTPUT 和 FORWARD 的預設策略是阻止。

我預計這將允許約翰訪問他的資源。但實際上他的所有請求都被阻止了。

我做錯了什麼?

更新1

新增完整程式碼:

#!/bin/sh
# flush all
iptables -F
iptables -X

# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

# Allow unlimited traffic on loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

iptables -A FORWARD -p tcp --source 10.8.0.1 --destination 10.8.1.1 -j ACCEPT

# make sure nothing comes or goes out of this box
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP

相關內容