Run sudo nano /var/lib/pritunl/plugins/custom_iptables.py
then add the code below. Then run sudo systemctl restart pritunl
.
from pritunl import logger
import subprocess
def server_start(host_id, host_name, server_id, server_name, network,
network_wg, interface, interface_wg, **kwargs):
logger.info('Adding custom iptables', 'plugin',
server_name=server_name,
interface=interface,
)
try:
subprocess.check_call([
'iptables',
'-I', 'FORWARD',
'-i', interface,
'-p', 'tcp',
'--dport', '22',
'-j', 'DROP'
])
except:
logger.exception('Failed to add custom iptables', 'plugin',
server_name=server_name,
interface=interface,
)
raise
def server_stop(host_id, host_name, server_id, server_name, network,
network_wg, interface, interface_wg, **kwargs):
logger.info('Removing custom iptables', 'plugin',
server_name=server_name,
interface=interface,
)
try:
subprocess.check_call([
'iptables',
'-D', 'FORWARD',
'-i', interface,
'-p', 'tcp',
'--dport', '22',
'-j', 'DROP'
])
except:
logger.exception('Failed to remove custom iptables', 'plugin',
server_name=server_name,
interface=interface,
)
raise