Iptables - transparently routing from VPS with multiple IPs to a local networks single IPHow to configure...

What happens if a wizard reaches level 20 but has no 3rd-level spells that they can use with the Signature Spells feature?

"Sheng" as a male given name

Predict mars robot position

Auto Insert date into Notepad

Why is c4 a better move in this position?

Is 45 min enough time to catch my next flight in Copenhagen?

Do my Windows system binaries contain sensitive information?

Dilemma of explaining to interviewer that he is the reason for declining second interview

LTSpice: When running a linear AC simulation, how to view the voltage ratio between two voltages?

How to satisfy a player character's curiosity about another player character?

Meth dealer reference in Family Guy

F1 visa even for a three-week course?

How to approximate rolls for potions of healing using only d6's?

Can I retract my name from an already published manuscript?

Can the Count of Monte Cristo's calculation of poison dosage be explained?

Finding ratio of the area of triangles

Could be quantum mechanics necessary to analyze some biology scenarios?

I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

Where was Karl Mordo in Infinity War?

Find the number of ways to express 1050 as sum of consecutive integers

ip vs ifconfig commands pros and cons

What's the purpose of these copper coils with resitors inside them in A Yamaha RX-V396RDS amplifier?

Sometimes a banana is just a banana

Which branches of mathematics can be done just in terms of morphisms and composition?



Iptables - transparently routing from VPS with multiple IPs to a local networks single IP


How to configure traffic from a specific IP hardcoded to an IP to forward to another IP:PORT using iptables?Linux IPTables Destination NAT with Asymmetrical Routing?Forward http traffic to another ip address with iptablesIPTables: NAT multiple IPs to one public IPLinux Port Forwarding to different IPsConfig differents external proxy to every VM with iptablesiptables port forwarding to server with different port(dnat|redirect) with masquerade doesn't workport forwarding to backend serveriptables port-redirect to proxy













0















I have a VPS with 3 IP addresses (the main one, and 2 extra ones). I want to route all traffic going to these 3 IPs to a local network, and maintain the source IP so my local network can redirect traffic to specific devices based on that.



The issue is that I cant get the routing to work on the VPS so traffic to each of the IP addresses of the VPS are sent to my local networks IP and appear unique to the local router



This is what I have so far in my iptables rules



-A PREROUTING -p tcp -m tcp --dport 9983 -j DNAT --to-destination LOCAL_IP:9983
-A PREROUTING -p tcp -m tcp --dport 7777 -j DNAT --to-destination LOCAL_IP:7777
-A PREROUTING -p tcp -m tcp --dport 11010 -j DNAT --to-destination LOCAL_IP:11010
-A POSTROUTING -j SNAT --to-source VPS_IP_1
-A POSTROUTING -j SNAT --to-source VPS_IP_1
-A POSTROUTING -j SNAT --to-source VPS_IP_2


however it appears only the one of the -A POSTROUTING -j SNAT --to-source works - eg on my local router I have some forwarding rules setup based on the source IP, if its VPS_IP_1 it goes to one device, if its VPS_IP_2 it goes to another, and so on... but regardless of which VPS IP i send traffic to, it always gets routed to the same device, as if all traffic was going to just one of the VPS IPs. If I reorder the -A POSTROUTING -j SNAT --to-source section of the rules it changes which VPS IP my local network thinks all the traffic is from.



Is this to do with the fact my local network is cable eg not a static IP? should i be using MASQUERADE instead of SNAT? I have tried combinations of



-A POSTROUTING -j SNAT --to-source VPS_IP_1
-A POSTROUTING -j SNAT --to-source VPS_IP_2
-A POSTROUTING -j SNAT --to-source VPS_IP_3


and



-A POSTROUTING -j MASQUERADE


to no avail. If I just use MASQUERADE only the main ip of the VPS sends traffic through to my local network, if I use MASQUERADE and SNAT together only one of the VPS ips seems to get through to my local network (appears to be the first VPS IP listed in the SNAT rules).



Im also not sure if my local modem or router is the root cause of the issue, I have opened the relevant ports on the modem (both tcp and udp) and have set up the router to forward traffic to specific devices based on source VPS ip, but perhaps the modem is garbling the source VPS ip somehow?










share|improve this question







New contributor




Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I have a VPS with 3 IP addresses (the main one, and 2 extra ones). I want to route all traffic going to these 3 IPs to a local network, and maintain the source IP so my local network can redirect traffic to specific devices based on that.



    The issue is that I cant get the routing to work on the VPS so traffic to each of the IP addresses of the VPS are sent to my local networks IP and appear unique to the local router



    This is what I have so far in my iptables rules



    -A PREROUTING -p tcp -m tcp --dport 9983 -j DNAT --to-destination LOCAL_IP:9983
    -A PREROUTING -p tcp -m tcp --dport 7777 -j DNAT --to-destination LOCAL_IP:7777
    -A PREROUTING -p tcp -m tcp --dport 11010 -j DNAT --to-destination LOCAL_IP:11010
    -A POSTROUTING -j SNAT --to-source VPS_IP_1
    -A POSTROUTING -j SNAT --to-source VPS_IP_1
    -A POSTROUTING -j SNAT --to-source VPS_IP_2


    however it appears only the one of the -A POSTROUTING -j SNAT --to-source works - eg on my local router I have some forwarding rules setup based on the source IP, if its VPS_IP_1 it goes to one device, if its VPS_IP_2 it goes to another, and so on... but regardless of which VPS IP i send traffic to, it always gets routed to the same device, as if all traffic was going to just one of the VPS IPs. If I reorder the -A POSTROUTING -j SNAT --to-source section of the rules it changes which VPS IP my local network thinks all the traffic is from.



    Is this to do with the fact my local network is cable eg not a static IP? should i be using MASQUERADE instead of SNAT? I have tried combinations of



    -A POSTROUTING -j SNAT --to-source VPS_IP_1
    -A POSTROUTING -j SNAT --to-source VPS_IP_2
    -A POSTROUTING -j SNAT --to-source VPS_IP_3


    and



    -A POSTROUTING -j MASQUERADE


    to no avail. If I just use MASQUERADE only the main ip of the VPS sends traffic through to my local network, if I use MASQUERADE and SNAT together only one of the VPS ips seems to get through to my local network (appears to be the first VPS IP listed in the SNAT rules).



    Im also not sure if my local modem or router is the root cause of the issue, I have opened the relevant ports on the modem (both tcp and udp) and have set up the router to forward traffic to specific devices based on source VPS ip, but perhaps the modem is garbling the source VPS ip somehow?










    share|improve this question







    New contributor




    Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I have a VPS with 3 IP addresses (the main one, and 2 extra ones). I want to route all traffic going to these 3 IPs to a local network, and maintain the source IP so my local network can redirect traffic to specific devices based on that.



      The issue is that I cant get the routing to work on the VPS so traffic to each of the IP addresses of the VPS are sent to my local networks IP and appear unique to the local router



      This is what I have so far in my iptables rules



      -A PREROUTING -p tcp -m tcp --dport 9983 -j DNAT --to-destination LOCAL_IP:9983
      -A PREROUTING -p tcp -m tcp --dport 7777 -j DNAT --to-destination LOCAL_IP:7777
      -A PREROUTING -p tcp -m tcp --dport 11010 -j DNAT --to-destination LOCAL_IP:11010
      -A POSTROUTING -j SNAT --to-source VPS_IP_1
      -A POSTROUTING -j SNAT --to-source VPS_IP_1
      -A POSTROUTING -j SNAT --to-source VPS_IP_2


      however it appears only the one of the -A POSTROUTING -j SNAT --to-source works - eg on my local router I have some forwarding rules setup based on the source IP, if its VPS_IP_1 it goes to one device, if its VPS_IP_2 it goes to another, and so on... but regardless of which VPS IP i send traffic to, it always gets routed to the same device, as if all traffic was going to just one of the VPS IPs. If I reorder the -A POSTROUTING -j SNAT --to-source section of the rules it changes which VPS IP my local network thinks all the traffic is from.



      Is this to do with the fact my local network is cable eg not a static IP? should i be using MASQUERADE instead of SNAT? I have tried combinations of



      -A POSTROUTING -j SNAT --to-source VPS_IP_1
      -A POSTROUTING -j SNAT --to-source VPS_IP_2
      -A POSTROUTING -j SNAT --to-source VPS_IP_3


      and



      -A POSTROUTING -j MASQUERADE


      to no avail. If I just use MASQUERADE only the main ip of the VPS sends traffic through to my local network, if I use MASQUERADE and SNAT together only one of the VPS ips seems to get through to my local network (appears to be the first VPS IP listed in the SNAT rules).



      Im also not sure if my local modem or router is the root cause of the issue, I have opened the relevant ports on the modem (both tcp and udp) and have set up the router to forward traffic to specific devices based on source VPS ip, but perhaps the modem is garbling the source VPS ip somehow?










      share|improve this question







      New contributor




      Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have a VPS with 3 IP addresses (the main one, and 2 extra ones). I want to route all traffic going to these 3 IPs to a local network, and maintain the source IP so my local network can redirect traffic to specific devices based on that.



      The issue is that I cant get the routing to work on the VPS so traffic to each of the IP addresses of the VPS are sent to my local networks IP and appear unique to the local router



      This is what I have so far in my iptables rules



      -A PREROUTING -p tcp -m tcp --dport 9983 -j DNAT --to-destination LOCAL_IP:9983
      -A PREROUTING -p tcp -m tcp --dport 7777 -j DNAT --to-destination LOCAL_IP:7777
      -A PREROUTING -p tcp -m tcp --dport 11010 -j DNAT --to-destination LOCAL_IP:11010
      -A POSTROUTING -j SNAT --to-source VPS_IP_1
      -A POSTROUTING -j SNAT --to-source VPS_IP_1
      -A POSTROUTING -j SNAT --to-source VPS_IP_2


      however it appears only the one of the -A POSTROUTING -j SNAT --to-source works - eg on my local router I have some forwarding rules setup based on the source IP, if its VPS_IP_1 it goes to one device, if its VPS_IP_2 it goes to another, and so on... but regardless of which VPS IP i send traffic to, it always gets routed to the same device, as if all traffic was going to just one of the VPS IPs. If I reorder the -A POSTROUTING -j SNAT --to-source section of the rules it changes which VPS IP my local network thinks all the traffic is from.



      Is this to do with the fact my local network is cable eg not a static IP? should i be using MASQUERADE instead of SNAT? I have tried combinations of



      -A POSTROUTING -j SNAT --to-source VPS_IP_1
      -A POSTROUTING -j SNAT --to-source VPS_IP_2
      -A POSTROUTING -j SNAT --to-source VPS_IP_3


      and



      -A POSTROUTING -j MASQUERADE


      to no avail. If I just use MASQUERADE only the main ip of the VPS sends traffic through to my local network, if I use MASQUERADE and SNAT together only one of the VPS ips seems to get through to my local network (appears to be the first VPS IP listed in the SNAT rules).



      Im also not sure if my local modem or router is the root cause of the issue, I have opened the relevant ports on the modem (both tcp and udp) and have set up the router to forward traffic to specific devices based on source VPS ip, but perhaps the modem is garbling the source VPS ip somehow?







      linux networking iptables vps tomato






      share|improve this question







      New contributor




      Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 13 hours ago









      Matthew PrasinovMatthew Prasinov

      101




      101




      New contributor




      Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Matthew Prasinov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Matthew Prasinov is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f956513%2fiptables-transparently-routing-from-vps-with-multiple-ips-to-a-local-networks%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Matthew Prasinov is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Matthew Prasinov is a new contributor. Be nice, and check out our Code of Conduct.













          Matthew Prasinov is a new contributor. Be nice, and check out our Code of Conduct.












          Matthew Prasinov is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f956513%2fiptables-transparently-routing-from-vps-with-multiple-ips-to-a-local-networks%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          117736 Шеррод Примітки | Див. також | Посилання | Навігаційне...

          As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

          Маріан Котлеба Зміст Життєпис | Політичні погляди |...