I want to set up a VPN that uses the client’s IP when sending data out of the VPN server. I am able to use either OpenVPN (open-source edition), or Wireguard.

  • rentar42@kbin.social
    link
    fedilink
    arrow-up
    10
    arrow-down
    1
    ·
    7 months ago

    This feels like a XY problem. To be able to provide a useful answer to you, we’d need to know what exactly you’re trying to achieve. What goal are you trying to achieve with the VPN and what goal are you trying to achieve by using the client IP?

    • SayCyberOnceMore@feddit.uk
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      7 months ago

      Thanks for the XY link… I’ve seen this occur loads of times, but that sums it up succinctly. Thanks

    • r00ty@kbin.life
      link
      fedilink
      arrow-up
      1
      ·
      7 months ago

      Yeah, not sure how many isps block it. They didn’t used to 10 years or so ago. I used to block unknown ips at my egress.

      But they should, and I’m hoping they do now.

      I’m also not too sure what the point would be for the OP. Even if their isp allows the ip spoofing the response would take the normal route back to the vpn client.

  • IsoKiero@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    6
    ·
    7 months ago

    While I think you could techincally spoof your originating IP at the VPN server to match your clients IP it wouldn’t do anything useful. That’s not how IP routing works. What you’re trying to achieve with a setup like that?

  • XenGi@lemmy.chaos.berlin
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    7 months ago

    In most cases the whole point of the VPN is to not disclose the clients IP. Are you talking about a site 2 site VPN? Then this would make sense. In that case you choose an IP range for the VPN endpoints and add routes to the networks in both ends over it. Then the clients will use their own IPs to connect and you should see them on the other side as source. Make sure to have no IP range overlaps.

    I can give you a simple example later if you want.

  • twinnie@feddit.uk
    link
    fedilink
    English
    arrow-up
    3
    ·
    7 months ago

    This can’t feasibly be done over the internet. An IP address must be unique as that’s how it finds it out of billions of other devices. There are situations where the same IP can route to different locations but that’s regional and way beyond what you’re trying to achieve here. It’s how something like 8.8.8.8 works without sending all the requests to a single location.

    If your server is sending out traffic as 1.2.3.4 and then tries to send the encrypted traffic to the client at 1.2.3.4 the traffic would either be routed back to itself or the client would receive the plaintext traffic meant for the server.

    • BearOfaTime@lemm.ee
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      7 months ago

      Depends.

      Generally, yea, this isn’t how a client-server VPN works.

      If you’re interconnecting two subnets that are part of the same network (say a remote site that uses a subnet of corporate address space) with a site-to-site vpn, then it can make sense. But then the VPN is usually transparent to the devices.

      A client using VPN to connect to a VPN server as an entry point would need some kind of subnetting functionality to achieve this, something like what Tailscale does with Subnet Routing. But that would be reproducing the site-to-site, and you’d need to make sure IP addressing is peoperly configured (the remote site needs to be part of the same address space with no conflicts).

      If you control both ends, this is possible with proper DHCP scoping/reservations, or just static addresses.

      But without really understanding OP’s intent, it’s hard to say.

  • Engywuck@lemm.ee
    link
    fedilink
    English
    arrow-up
    2
    ·
    7 months ago

    Uh? Is this a thing? And, if it is, what’s the use case? Just curious…

  • Decronym@lemmy.decronym.xyzB
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    7 months ago

    Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

    Fewer Letters More Letters
    HTTP Hypertext Transfer Protocol, the Web
    IP Internet Protocol
    NAT Network Address Translation
    VPN Virtual Private Network
    VPS Virtual Private Server (opposed to shared hosting)

    5 acronyms in this thread; the most compressed thread commented on today has 7 acronyms.

    [Thread #364 for this sub, first seen 19th Dec 2023, 09:15] [FAQ] [Full list] [Contact] [Source code]

    • dan@upvote.au
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      7 months ago

      I don’t think this will actually work. If data looks like it’s coming from the client IP, the return packets will take the wrong route and go directly to the client instead of via the proxy/VPN.

  • Max-P@lemmy.max-p.me
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    1
    ·
    7 months ago

    That’s not possible. There’s only one route to an IP. Those may lead to different machines depending on where the request originates, and you more or less can’t choose which one, your ISP and their upstream ISPs decide and it’s usually the shortest or cheapest route. The Internet is stateless, it just moves packets around. Each step makes an independent decision as to where to send it next.

    So your VPN server can try spoofing its outbound traffic to use the client’s IP, but it’ll most likely get discarded by the ISP because it only allows your IP to go out. But even if you can, the answer to those packets will go to the client’s IP, which will go directly to the client and not the VPN. The other end doesn’t know where it originated from, it just has a number, and it sends it back into the Internet and the Internet figures it out.

    And if you can properly port the IP to your server, then the client can no longer use that IP because anything directed at it will end up at the server.

    It’s theoretically possible to pull off with some clever iptables rules but both ends need to be configured for it so it’ll never leave your private network. In which case, it’s just not worth the hassle to avoid making a new subnet.

    • Atemu@lemmy.ml
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      1
      ·
      7 months ago

      There’s only one route to an IP.

      That’s not true. There’s an infinite numer of ways to route IP addresses on the internet in fact. Most of them are useless however.

      your VPN server can try spoofing its outbound traffic to use the client’s IP, but it’ll most likely get discarded by the ISP because it only allows your IP to go out. But even if you can, the answer to those packets will go to the client’s IP, which will go directly to the client and not the VPN.

      Mission accomplished? This may be what OP wants? Really not sure.

      • dan@upvote.au
        link
        fedilink
        English
        arrow-up
        3
        ·
        7 months ago

        That’s not true. There’s an infinite numer of ways to route IP addresses on the internet

        I think what they were trying to say is that packets are usually routed one particular way, which is true (routes normally don’t suddenly change). This part of their comment makes me think they do understand that there’s many possible routes:

        you more or less can’t choose which one, your ISP and their upstream ISPs decide and it’s usually the shortest or cheapest route.

        • Max-P@lemmy.max-p.me
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          1
          ·
          7 months ago

          Yeah, I almost talked about anycast IPs but it just added unnecessary complexity.

          OP’s question is a bit weird but it sounds like they want to connect to a VPN server and then that server uses the client’s IP instead of its own for outbound traffic, like some sort of forwarding?

          For all I know OP may be asking for a bridged VPN and it really just means to forward the remote client as if it’s on the local network.

          But the way it’s worded, the same IP would be used to both talk to the server and by the server itself going outbound. It’s possible on a local network with iptables hacks but why would you even want to do this?

    • IsoKiero@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      9
      ·
      7 months ago

      Not necessarily. VPN can be used for that, but I’d be that more common use case is to access networks which are otherwise firewalled off from the public internet, like corporate LAN.

    • Atemu@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      7 months ago

      Not at all. A VPN can be used as a proxy but that’s not what they were intended for.

      • dan@upvote.au
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        7 months ago

        I do wonder about when VPNs started being used as proxies… Back when I was in school, we’d use HTTP proxies for HTTP, and SOCKS5 proxies for everything else. I remember I’d try searching for free web-based proxies too.

        I guess VPNs being easier to configure and automatically applying to all apps (since they’re just networks that can have routing rules) helped.

        • IsoKiero@sopuli.xyz
          link
          fedilink
          English
          arrow-up
          1
          ·
          7 months ago

          I do wonder about when VPNs started being used as proxies…

          About at the same time operators at the US noticed that they could profit from profiling users behaviour. In here that’s very much illegal thing to do and most use cases for VPN is to connect yourself into corporate network. VPNs are of course useful to protect you from MITM attacks at open wifi networks and things like that, but hiding your behavior from your ISP is very much an US thing.