У меня есть три сегмента за сервером openvpn: DMZ (192.168.1.x
), Dev (192.168.2.x
) и ПРОД (192.168.3.x
). Есть две группы пользователей: одна группа может подключаться ко всем сегментам из openvpn, в то время как я хочу ограничить других пользователей сегментом Dev. Как лучше всего это сделать?
Пользователям OpenVPN назначаются IP-адреса в 10.10.11.x
сеть.
Лучший способ сделать это - предоставить каждой группе отдельную подсеть / 24 или разбить 10.10.11.0/24 и применить магию iptables, чтобы заблокировать пользователей-разработчиков.
Но я думаю, что лучше всего, если ваша сеть поддерживает это, - это использовать теги vlan для каждой подсети. Предоставьте разработчикам их собственный / 24 в openvpn, а затем несколько правил брандмауэра, чтобы разрешить dev vlan подключаться только к определенным другим ланам.
Для openvpn есть переключатель под названием --learn-address
, который можно использовать для создания правил ...
В этом скрипте вы в основном проверяете CN и добавляете / удаляете правила iptables для IP.
извлечение из openvpn MAN:
--learn-address cmd
Run script or shell command cmd to validate client virtual
addresses or routes.
cmd will be executed with 3 parameters:
[1] operation -- "add", "update", or "delete" based on whether
or not the address is being added to, modified, or deleted from
OpenVPN's internal routing table.
[2] address -- The address being learned or unlearned. This can
be an IPv4 address such as "198.162.10.14", an IPv4 subnet such
as "198.162.10.0/24", or an ethernet MAC address (when --dev tap
is being used) such as "00:FF:01:02:03:04".
[3] common name -- The common name on the certificate associated
with the client linked to this address. Only present for "add"
or "update" operations, not "delete".
On "add" or "update" methods, if the script returns a failure
code (non-zero), OpenVPN will reject the address and will not
modify its internal routing table.
Normally, the cmd script will use the information provided above
to set appropriate firewall entries on the VPN TUN/TAP inter‐
face. Since OpenVPN provides the association between virtual IP
or MAC address and the client's authenticated common name, it
allows a user-defined script to configure firewall access poli‐
cies with regard to the client's high-level common name, rather
than the low level client virtual addresses.