LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-01-2018, 08:10 AM   #1
keysman75
LQ Newbie
 
Registered: Oct 2009
Location: Rimini, Italy
Distribution: Ubuntu
Posts: 3

Rep: Reputation: 0
Question Forward traffic via two OpenVPN connections to two different internal IPs: IPTABLES issue?


Good afternoon to everybody. I have an IPTABLES issue for forwarding
traffic from two OpenVPN connection to two internal servers.

Here below my interfaces' config file:

# The primary network interface
auto enp4s0
iface enp4s0 inet dhcp

# The Virtual NIC
auto enp4s0:0
iface enp4s0:0 inet static
address 192.168.90.1
netmask 255.255.255.0

Running ifconfig:
enp4s0 Link encap:Ethernet HWaddr d0:bf:9c:19:3c:8b
inet addr:192.168.88.10 Bcast:192.168.88.255 Mask:255.255.255.0

enp4s0:0 Link encap:Ethernet HWaddr d0:bf:9c:19:3c:8b
inet addr:192.168.90.1 Bcast:192.168.90.255 Mask:255.255.255.0


tap0 Link encap:Ethernet HWaddr 3a:c9:eb:1d:c6:91
inet addr:192.168.0.196 Bcast:192.168.0.255 Mask:255.255.255.0


tap1 Link encap:Ethernet HWaddr c6:3c:8e:d9:77:39
inet addr:192.168.0.197 Bcast:192.168.0.255 Mask:255.255.255.0

I have two internal server (192.168.90.10 and 192.168.90.11) and I have to forward traffic in the following way:
192.168.0.196 (tap0) <- -> 192.168.90.10
192.168.0.197 (tap1) <- -> 192.168.90.11

Actually if I open 192.168.0.196 and/or 192.168.0.197, replies comes always from the 192.168.90.11.

My rules.v4 files is:
-A FORWARD -i enp4s0:0 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i enp4s0:0 -o tap0 -j ACCEPT
-A FORWARD -i enp4s0:0 -o tap1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i enp4s0:0 -o tap1 -j ACCEPT

-A PREROUTING -i tap0 -p tcp -m tcp ! --dport 22 -j DNAT --to-destination 192.168.90.10
-A PREROUTING -i tap0 -p udp -m udp -j DNAT --to-destination 192.168.90.11

-A PREROUTING -i tap1 -p tcp -m tcp ! --dport 22 -j DNAT --to-destination 192.168.90.11
-A PREROUTING -i tap1 -p udp -m udp -j DNAT --to-destination 192.168.91.11

-A POSTROUTING -o tap0 -j MASQUERADE
-A POSTROUTING -o tap1 -j MASQUERADE


What I misconfigurated??

Thanks in advance
 
Old 08-01-2018, 10:02 AM   #2
keysman75
LQ Newbie
 
Registered: Oct 2009
Location: Rimini, Italy
Distribution: Ubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
I did an update to rules.v4 file and it works with tun0 only:

-A FORWARD -i enp4s0:0 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i enp4s0:0 -o tap0 -j ACCEPT
-A PREROUTING -i tap0 -p tcp -m tcp ! --dport 22 -j DNAT --to-destination 192.168.90.11
-A PREROUTING -i tap0 -p udp -m udp -j DNAT --to-destination 192.168.90.11
-A POSTROUTING -o tap0 -j MASQUERADE

Adding the same rules for tun1 it fails: only tun0 keep on works.

What is the right way to add the forward to 90.12 ? What mistake I did?

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] iptables - forward traffic through squid when connected via openvpn NotTheBoyIUsedToBe Linux - Security 4 07-17-2014 06:35 AM
Returning internal traffic based on destination IP to another internal IP - iptables opti2k4 Linux - Security 5 10-27-2013 02:56 PM
OpenVPN sometimes does not forward all traffic to server depam Linux - Software 1 06-28-2008 04:13 PM
How to forward traffic to one subdomain do a different internal IP. E211 Linux - Server 3 06-10-2008 11:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration