How to install iptables as a systemd service and allow outgoing connection to Synology NAS
Subject: How to install iptables as a systemd service and allow outgoing connection to Synology NAS
Author: Mr. Turritopsis Dohrnii Teo En Ming (TARGETED INDIVIDUAL)
Country: Singapore
Date: 22 August 2021 Sunday Singapore Time
Type of Publication: Plain Text
Document version: 20210822.01
DETAILED STEPS
===============
Save the existing iptables firewall rules to a file named /etc/sysconfig/iptables.
# iptables-save > /etc/sysconfig/iptables
Add the following lines to /etc/sysconfig/iptables, to allow outgoing connection to Synology NAS.
Assume 192.168.1.5 is the IP address of the Synology NAS.
# nano /etc/sysconfig/iptables
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p tcp -m tcp --dport 135:139 -j ACCEPT
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p udp -m udp --dport 135:139 -j ACCEPT
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p tcp -m tcp --sport 135:139 -j ACCEPT
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p udp -m udp --sport 135:139 -j ACCEPT
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p tcp -m tcp --dport 445 -j ACCEPT
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p udp -m udp --dport 445 -j ACCEPT
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p tcp -m tcp --sport 445 -j ACCEPT
-A OUTPUT -d 192.168.1.5/32 ! -o lo -p udp -m udp --sport 445 -j ACCEPT
Reload iptables firewall rules from /etc/sysconfig/iptables.
# iptables-restore < /etc/sysconfig/iptables
Install iptables systemd service.
# yum install iptables-services
Start iptables systemd service.
# systemctl start iptables
Allow iptables systemd service to start across reboots.
# systemctl enable iptables
# service iptables save
Above command will save iptables firewall rules into /etc/sysconfig/iptables.
Mr. Turritopsis Dohrnii Teo En Ming, 43 years old as of 22 August 2021, is a TARGETED INDIVIDUAL living in Singapore. He is an IT Consultant with a System Integrator (SI)/computer firm in Singapore. He is an IT enthusiast.
REFERENCES
===========
Comments
Post a Comment