Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Routing specific LAN segment via OpenVPN tunnel

    Scheduled Pinned Locked Moved Routing and Multi WAN
    35 Posts 5 Posters 4.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kroem
      last edited by

      @johnpoz:

      "The traffic 80.239.147.29.42200 > 10.128.164.2.59362"

      Yes this coming into your vpn interface.

      So sniff your vlan99 interface when you do that, is your port forward sending it out the vlan99 interface to your client and is your client answering back to pfsense?

      I appreciate your help - but really, that information is already in the thread :) I have a TCPdump of my VLAN99 interface above, you can see that packets are being sent between the same IP's when it's "working" (ping test outbound) and not working (Iperf session inbound)

      [2.3.3-RELEASE][root@fw-pf.kroem.eu]/root: tcpdump -i igb1_vlan99 -nn host 80.239.147.29
      tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
      listening on igb1_vlan99, link-type EN10MB (Ethernet), capture size 65535 bytes
      22:10:55.944376 IP 80.239.147.29.42200 > 10.99.1.201.59362: Flags [s], seq 3526785419, win 29200, options [mss 1349,sackOK,TS val 34928838 ecr 0,nop,wscale 7], length 0
      22:10:55.944659 IP 10.99.1.201.59362 > 80.239.147.29.42200: Flags [S.], seq 2629731937, ack 3526785420, win 28960, options [mss 1460,sackOK,TS val 33974369 ecr 34928838,nop,wscale 7], length 0
      22:10:56.943438 IP 80.239.147.29.42200 > 10.99.1.201.59362: Flags [s], seq 3526785419, win 29200, options [mss 1349,sackOK,TS val 34929088 ecr 0,nop,wscale 7], length 0
      22:10:56.943652 IP 10.99.1.201.59362 > 80.239.147.29.42200: Flags [S.], seq 2629731937, ack 3526785420, win 28960, options [mss 1460,sackOK,TS val 33974619 ecr 34928838,nop,wscale 7], length 0
      22:10:58.141497 IP 10.99.1.201.59362 > 80.239.147.29.42200: Flags [S.], seq 2629731937, ack 3526785420, win 28960, options [mss 1460,sackOK,TS val 33974919 ecr 34928838,nop,wscale 7], length 0
      22:10:58.947546 IP 80.239.147.29.42200 > 10.99.1.201.59362: Flags [s], seq 3526785419, win 29200, options [mss 1349,sackOK,TS val 34929589 ecr 0,nop,wscale 7], length 0
      22:10:58.947812 IP 10.99.1.201.59362 > 80.239.147.29.42200: Flags [S.], seq 2629731937, ack 3526785420, win 28960, options [mss 1460,sackOK,TS val 33975120 ecr 34928838,nop,wscale 7], length 0
      22:11:01.341273 IP 10.99.1.201.59362 > 80.239.147.29.42200: Flags [S.], seq 2629731937, ack 3526785420, win 28960, options [mss 1460,sackOK,TS val 33975719 ecr 34928838,nop,wscale 7], length 0
      22:11:02.955574 IP 10.99.1.201 > 80.239.147.29: ICMP echo request, id 2099, seq 1, length 64
      22:11:02.977335 IP 80.239.147.29 > 10.99.1.201: ICMP echo reply, id 2099, seq 1, length 64
      22:11:03.956783 IP 10.99.1.201 > 80.239.147.29: ICMP echo request, id 2099, seq 2, length 64
      22:11:03.978472 IP 80.239.147.29 > 10.99.1.201: ICMP echo reply, id 2099, seq 2, length 64
      22:11:04.957965 IP 10.99.1.201 > 80.239.147.29: ICMP echo request, id 2099, seq 3, length 64
      22:11:04.979579 IP 80.239.147.29 > 10.99.1.201: ICMP echo reply, id 2099, seq 3, length 64
      22:11:05.959203 IP 10.99.1.201 > 80.239.147.29: ICMP echo request, id 2099, seq 4, length 64
      22:11:05.980780 IP 80.239.147.29 > 10.99.1.201: ICMP echo reply, id 2099, seq 4, length 64
      
      Here is the same test from the actual VM, you see the inbound connection attempt and a reply. Then I run a ping test, which is successful: 
      [code]root@vm1:~# tcpdump -i eth1 -nn host 80.239.147.29
      tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
      listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
      21:41:02.315127 IP 80.239.147.29.59236 > 10.99.1.201.59362: Flags [s], seq 2689225177, win 29200, options [mss 1349,sackOK,TS val 56078236 ecr 0,nop,wscale 7], length 0
      21:41:02.315179 IP 10.99.1.201.59362 > 80.239.147.29.59236: Flags [S.], seq 2659676728, ack 2689225178, win 28960, options [mss 1460,sackOK,TS val 55124643 ecr 56078236,nop,wscale 7], length 0
      21:41:03.312092 IP 80.239.147.29.59236 > 10.99.1.201.59362: Flags [s], seq 2689225177, win 29200, options [mss 1349,sackOK,TS val 56078486 ecr 0,nop,wscale 7], length 0
      21:41:03.312126 IP 10.99.1.201.59362 > 80.239.147.29.59236: Flags [S.], seq 2659676728, ack 2689225178, win 28960, options [mss 1460,sackOK,TS val 55124893 ecr 56078236,nop,wscale 7], length 0
      21:41:04.712097 IP 10.99.1.201.59362 > 80.239.147.29.59236: Flags [S.], seq 2659676728, ack 2689225178, win 28960, options [mss 1460,sackOK,TS val 55125243 ecr 56078236,nop,wscale 7], length 0
      21:41:06.604111 IP 10.99.1.201 > 80.239.147.29: ICMP echo request, id 3025, seq 1, length 64
      21:41:06.626188 IP 80.239.147.29 > 10.99.1.201: ICMP echo reply, id 3025, seq 1, length 64
      21:41:07.605414 IP 10.99.1.201 > 80.239.147.29: ICMP echo request, id 3025, seq 2, length 64
      21:41:07.627132 IP 80.239.147.29 > 10.99.1.201: ICMP echo reply, id 3025, seq 2, length 64
      
      The commands, for ref:
      [code]root@vm1:~# iperf3 -s -p 59362
      -----------------------------------------------------------
      Server listening on 59362
      -----------------------------------------------------------
      ^Ciperf3: interrupt - the server has terminated
      root@vm1:~# ping 80.239.147.29
      PING 80.239.147.29 (80.239.147.29) 56(84) bytes of data.
      64 bytes from 80.239.147.29: icmp_seq=1 ttl=55 time=22.0 ms
      64 bytes from 80.239.147.29: icmp_seq=2 ttl=55 time=21.7 ms
      ^C
      --- 80.239.147.29 ping statistics ---
      2 packets transmitted, 2 received, 0% packet loss, time 1001ms
      rtt min/avg/max/mdev = 21.741/21.912/22.084/0.226 ms[/code]
      
      [quote]
      You could have an asymmetrical issue where pfsense sends it on to your host on your vlan99..  But vlan99 host is sending it to a different IP as its gateway?
      [/quote]
      Yes, that is what is happening, but only when traffic is established from outside. I'm not surte what I'm doing wrong, or pfsense doing wrong or how to fix it
      
      [quote]Also it seems you have multiple threads about the same topic??  You should have the mods merge them!!!
      [/quote]
      
      I appreciate your help - but really, that information is already in the thread :) I have a TCPdump of my VLAN99 interface above, you can see that packets are being sent between the same IP's when it's "working" (ping test outbound) and not working (Iperf session inbound) 
      
      I do not have multiple threads, but I cant help it if there's other that see about the same issue :) 
      
      [quote]
      Have you posted your port forwards for your vpn interface?
      [/quote]
      Attaching it below.
      
      [quote]
      I think it would also be helpful to see the rules from the "OPT" interface assigned to the tunnel as well.
      [/quote]
      They are in my post above, when you asked if the rules where on the wrong interface. "OVPN" interface is the OPT interface assigned to the tunnel (on my pfsense box that is, I do not have access to the server which is hosted).
      
      Did you get a chance to see if you can hit the scenario yourself? This is getting interesting, some real troubleshooting :) 
      
      ![Skärmklipp 2017-05-26 21.37.12.png](/public/_imported_attachments_/1/Skärmklipp 2017-05-26 21.37.12.png)
      ![Skärmklipp 2017-05-26 21.37.12.png_thumb](/public/_imported_attachments_/1/Skärmklipp 2017-05-26 21.37.12.png_thumb)[/s][/s][/code][/s][/s][/s]
      
      1 Reply Last reply Reply Quote 0
      • C
        CuteBoi
        last edited by

        My problem seems to be the same as  Kroem's.  I had made mine around the same time he did.

        He's on 2.3.3, I'm on 2.3.4

        1 Reply Last reply Reply Quote 0
        • johnpozJ
          johnpoz LAYER 8 Global Moderator
          last edited by

          Ok - so I signed up for trial… Bing bang zoom working!!

          I created client connection per their instructions - which are nice btw..

          I then setup policy routing to send my client 192.168.9.100 out the vpn
          Checked my IP!  Yup going out the vpn
          Setup the port forward to send that port to the same port on my box 192.168.9.100
          Fired up HFS to listen on 58703
          Checked if port was open on canyouseeme.org - boom Works!

          You can see the packet capture on the ovpn interface created, and then sniff on my lan and you can see my 192.168.9.100 box respond..

          So I suggest you post up the same screenshots I posted..

          workshere.png
          workshere.png_thumb

          An intelligent man is sometimes forced to be drunk to spend time with his fools
          If you get confused: Listen to the Music Play
          Please don't Chat/PM me for help, unless mod related
          SG-4860 24.11 | Lab VMs 2.8, 24.11

          1 Reply Last reply Reply Quote 0
          • C
            CuteBoi
            last edited by

            What was your "default gateway"?

            Because ours isn't the VPN gateway, we only want select systems to use that tunnel.

            I can make port forwarding work flawlessly if I change my default gateway.

            1 Reply Last reply Reply Quote 0
            • K
              kroem
              last edited by

              @johnpoz:

              Ok - so I signed up for trial… Bing bang zoom working!!

              I created client connection per their instructions - which are nice btw..

              I then setup policy routing to send my client 192.168.9.100 out the vpn
              Checked my IP!  Yup going out the vpn
              Setup the port forward to send that port to the same port on my box 192.168.9.100
              Fired up HFS to listen on 58703
              Checked if port was open on canyouseeme.org - boom Works!

              You can see the packet capture on the ovpn interface created, and then sniff on my lan and you can see my 192.168.9.100 box respond..

              So I suggest you post up the same screenshots I posted..

              As CuteBoi said, if it's just a default gateway there is no problem…

              1 Reply Last reply Reply Quote 0
              • C
                CuteBoi
                last edited by

                I just tried something, for fun.

                If this works for you, I would ask WHY.  I would not want to allow an any to any rule on a VPN interface.

                Add an Any to any rule in your VPN interface at the TOP, over your port forward entries.

                Image attached.

                ![Screenshot from 2017-05-27 02-40-35.png](/public/imported_attachments/1/Screenshot from 2017-05-27 02-40-35.png)
                ![Screenshot from 2017-05-27 02-40-35.png_thumb](/public/imported_attachments/1/Screenshot from 2017-05-27 02-40-35.png_thumb)

                1 Reply Last reply Reply Quote 0
                • K
                  kroem
                  last edited by

                  @CuteBoi:

                  I just tried something, for fun.

                  If this works for you, I would ask WHY.  I would not want to allow an any to any rule on a VPN interface.

                  Add an Any to any rule in your VPN interface at the TOP, over your port forward entries.

                  Image attached.

                  That will match any and send that to default gateway, never hiting the next rule (right?)

                  Edit. Also, I do not have any rules pointing to a gateway for traffic incoming on the OpenVPN interface, only outbound. (I tried changing the portforward rule to point at my OVPN gateway - no difference)

                  I did notice something that the rules do not log packets… Maybe it's not being hit at all. Im going away for a week now so will have to look later....

                  1 Reply Last reply Reply Quote 0
                  • johnpozJ
                    johnpoz LAYER 8 Global Moderator
                    last edited by

                    Dude not the default gateway…  I did it via policy routing!

                    Even though they did not put it in the instructions - you need to check the dont pull routes in your client settings.

                    "I do not have any rules pointing to a gateway for traffic incoming on the OpenVPN interface"

                    You wouldn't!!

                    An intelligent man is sometimes forced to be drunk to spend time with his fools
                    If you get confused: Listen to the Music Play
                    Please don't Chat/PM me for help, unless mod related
                    SG-4860 24.11 | Lab VMs 2.8, 24.11

                    1 Reply Last reply Reply Quote 0
                    • K
                      kroem
                      last edited by

                      @johnpoz:

                      Dude not the default gateway…  I did it via policy routing!

                      Even though they did not put it in the instructions - you need to check the dont pull routes in your client settings.

                      "I do not have any rules pointing to a gateway for traffic incoming on the OpenVPN interface"

                      You wouldn't!!

                      Of course I'm not pulling routes because I want to do this via policy routing, naturally.

                      1 Reply Last reply Reply Quote 0
                      • K
                        kroem
                        last edited by

                        Anyone else got any input on this? Would it be worthwhile to maybe post a bug-report?

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.