Trying to route a port to another IP

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:



echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"


Where my Pi's local IP is 192.168.1.80, in the VPN interface my linux computer's IP is 25.61.168.0. My Pi is connected to my network on interface eth0 and the VPN interface is labeled ham0.



In the browser, when I type 192.168.1.80:81 I want it to be redirected to 25.61.168.0:32400 on the Pi.



My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!










share|improve this question

























    up vote
    0
    down vote

    favorite












    I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:



    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
    iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
    iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"


    Where my Pi's local IP is 192.168.1.80, in the VPN interface my linux computer's IP is 25.61.168.0. My Pi is connected to my network on interface eth0 and the VPN interface is labeled ham0.



    In the browser, when I type 192.168.1.80:81 I want it to be redirected to 25.61.168.0:32400 on the Pi.



    My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:



      echo 1 > /proc/sys/net/ipv4/ip_forward
      iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
      iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
      iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"


      Where my Pi's local IP is 192.168.1.80, in the VPN interface my linux computer's IP is 25.61.168.0. My Pi is connected to my network on interface eth0 and the VPN interface is labeled ham0.



      In the browser, when I type 192.168.1.80:81 I want it to be redirected to 25.61.168.0:32400 on the Pi.



      My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!










      share|improve this question













      I have a raspberry pi on my local home network and a linux computer on an external location. The pi and the linux computer is connected with VPN (hamachi) but I want du add an IP forward rule so that all devices on my local home network can access a specified port on my linux server through my Pi. I've tried the following in the terminal on my Pi:



      echo 1 > /proc/sys/net/ipv4/ip_forward
      iptables -t nat -A PREROUTING -p tcp -d 192.168.1.80 --dport 81 -j DNAT --to 25.61.168.0:32400
      iptables -A FORWARD -p tcp -d 25.61.168.0 --dport 32400 -j ACCEPT
      iptables -t nat -A POSTROUTING -p tcp --dst 25.61.168.0 -j LOG --log-level warning --log-prefix "[REQUEST_FORWARDED]"


      Where my Pi's local IP is 192.168.1.80, in the VPN interface my linux computer's IP is 25.61.168.0. My Pi is connected to my network on interface eth0 and the VPN interface is labeled ham0.



      In the browser, when I type 192.168.1.80:81 I want it to be redirected to 25.61.168.0:32400 on the Pi.



      My code is not working, it tries to connect for like a minute before it terminates. Does anyone know why? Thanks in advance!







      networking iptables routing






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 26 '17 at 9:38









      Christian Lindland

      11




      11

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394497%2ftrying-to-route-a-port-to-another-ip%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394497%2ftrying-to-route-a-port-to-another-ip%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay