netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hack3rcon@mail2tor.com
To: netfilter@vger.kernel.org
Subject: I need help about to rewrite some iptables rules
Date: Tue, 1 Aug 2023 06:01:11 -0400	[thread overview]
Message-ID: <ab5de8002b9af064582103c4ae386878.squirrel@_> (raw)

Hello,
I have an OpenVPN server that has a NIC with two virtual IP addresses:

enp3s0     :  1.2.3.4
enp3s0:1   :  1.2.3.5
enp3s0:2   :  1.2.3.6

Each NIC runs two OpenVPN servers:

Server1.conf :
Tun1
1194
10.10.0.0/16

Server2.conf :
Tun2
1195
10.11.0.0/16

Server3.conf :
Tun3
1196
10.12.0.0/16

Server4.conf :
Tun4
1197
10.13.0.0/16


I use the following iptables rules:


# IF_MAIN=enp0s3
# IF_TUNNEL=tun2
# YOUR_OPENVPN_SUBNET=IP/16
# iptables -I INPUT -p udp --dport PORT -j ACCEPT
# iptables -A FORWARD -i $IF_MAIN -o $IF_TUNNEL -m state --state
ESTABLISHED,RELATED -j ACCEPT
# iptables -A FORWARD -s $YOUR_OPENVPN_SUBNET -o $IF_MAIN -j ACCEPT
# iptables -t nat -A POSTROUTING -s $YOUR_OPENVPN_SUBNET -o $IF_MAIN -j
MASQUERADE
# iptables -t nat -A POSTROUTING -s $YOUR_OPENVPN_SUBNET -j SNAT --to
$Virtual_NIC_IP


And for each IP address I must rewrite them. When the number of my servers
increases, this is a hard task. How can I reduce these iptables rules?
I'm thankful if anyone write some rules.


Thank you.


                 reply	other threads:[~2023-08-01 10:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab5de8002b9af064582103c4ae386878.squirrel@_ \
    --to=hack3rcon@mail2tor.com \
    --cc=netfilter@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).