How to route between interfaces

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 the following setup:



 (192.168.4.1) 
Device A <-------> device B <-------> Device C
(192.168.5.84) (192.168.5.1) (192.168.4.5)


Device B actually has an wifi interface (wlan0 = 192.168.4.1) on which an dhcp server is running. Then there is an cables interface (eth0 = 192.168.5.1).



What I want to reach is that devices A and C can talk to each other. I have been reading how to get to this result and I have found that I should use routing to accomplish this. I have tried some things and I do not understand why it is not working.



Device A has an static ip (subnet 255.255.255.0 and gateway 192.168.5.1).



Device C received an ip from the DHCP server (subnet 255.255.255.0 and gateway 192.168.4.1).



What I have done:



On device B I have set enabled the ipforward in /etc/sysctl



Added routing:



iptables -A FORWARD -i eth0 -o wlan0 -s 192.168.5.0/24 -d 192.168.4.0/24 -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.4.0/24 -d 192.168.5.0/24 -j ACCEPT


The thing is that both device A and C are accessible from device B, so this would indicate that it MUST be a routing issue. So my question is, how do I get to the situation where device B routes the traffic from A to C?




Update: What I failed to mention is that I want to accomplish this result by ONLY changing the settings of device B







share|improve this question

























    up vote
    0
    down vote

    favorite












    I have the following setup:



     (192.168.4.1) 
    Device A <-------> device B <-------> Device C
    (192.168.5.84) (192.168.5.1) (192.168.4.5)


    Device B actually has an wifi interface (wlan0 = 192.168.4.1) on which an dhcp server is running. Then there is an cables interface (eth0 = 192.168.5.1).



    What I want to reach is that devices A and C can talk to each other. I have been reading how to get to this result and I have found that I should use routing to accomplish this. I have tried some things and I do not understand why it is not working.



    Device A has an static ip (subnet 255.255.255.0 and gateway 192.168.5.1).



    Device C received an ip from the DHCP server (subnet 255.255.255.0 and gateway 192.168.4.1).



    What I have done:



    On device B I have set enabled the ipforward in /etc/sysctl



    Added routing:



    iptables -A FORWARD -i eth0 -o wlan0 -s 192.168.5.0/24 -d 192.168.4.0/24 -j ACCEPT
    iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.4.0/24 -d 192.168.5.0/24 -j ACCEPT


    The thing is that both device A and C are accessible from device B, so this would indicate that it MUST be a routing issue. So my question is, how do I get to the situation where device B routes the traffic from A to C?




    Update: What I failed to mention is that I want to accomplish this result by ONLY changing the settings of device B







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have the following setup:



       (192.168.4.1) 
      Device A <-------> device B <-------> Device C
      (192.168.5.84) (192.168.5.1) (192.168.4.5)


      Device B actually has an wifi interface (wlan0 = 192.168.4.1) on which an dhcp server is running. Then there is an cables interface (eth0 = 192.168.5.1).



      What I want to reach is that devices A and C can talk to each other. I have been reading how to get to this result and I have found that I should use routing to accomplish this. I have tried some things and I do not understand why it is not working.



      Device A has an static ip (subnet 255.255.255.0 and gateway 192.168.5.1).



      Device C received an ip from the DHCP server (subnet 255.255.255.0 and gateway 192.168.4.1).



      What I have done:



      On device B I have set enabled the ipforward in /etc/sysctl



      Added routing:



      iptables -A FORWARD -i eth0 -o wlan0 -s 192.168.5.0/24 -d 192.168.4.0/24 -j ACCEPT
      iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.4.0/24 -d 192.168.5.0/24 -j ACCEPT


      The thing is that both device A and C are accessible from device B, so this would indicate that it MUST be a routing issue. So my question is, how do I get to the situation where device B routes the traffic from A to C?




      Update: What I failed to mention is that I want to accomplish this result by ONLY changing the settings of device B







      share|improve this question













      I have the following setup:



       (192.168.4.1) 
      Device A <-------> device B <-------> Device C
      (192.168.5.84) (192.168.5.1) (192.168.4.5)


      Device B actually has an wifi interface (wlan0 = 192.168.4.1) on which an dhcp server is running. Then there is an cables interface (eth0 = 192.168.5.1).



      What I want to reach is that devices A and C can talk to each other. I have been reading how to get to this result and I have found that I should use routing to accomplish this. I have tried some things and I do not understand why it is not working.



      Device A has an static ip (subnet 255.255.255.0 and gateway 192.168.5.1).



      Device C received an ip from the DHCP server (subnet 255.255.255.0 and gateway 192.168.4.1).



      What I have done:



      On device B I have set enabled the ipforward in /etc/sysctl



      Added routing:



      iptables -A FORWARD -i eth0 -o wlan0 -s 192.168.5.0/24 -d 192.168.4.0/24 -j ACCEPT
      iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.4.0/24 -d 192.168.5.0/24 -j ACCEPT


      The thing is that both device A and C are accessible from device B, so this would indicate that it MUST be a routing issue. So my question is, how do I get to the situation where device B routes the traffic from A to C?




      Update: What I failed to mention is that I want to accomplish this result by ONLY changing the settings of device B









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jun 13 at 14:19
























      asked Jun 13 at 8:09









      Steven

      213




      213




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          No need to use iptables. If you have successfully enabled the ip forwarding, device B will do the job because both networks are directly connected to B. The thing you might missing are the correct routes on device A and C.
          On A:



          ip route add 192.168.4.0/24 via 192.168.5.1


          On C:



          ip route add 192.168.5.0/24 via 192.168.4.1





          share|improve this answer





















          • Ok yes, this worked! However this made me realize that I did not explain my question properly. The question I now have: how can I accomplish this with ONLY changing the settings of device B? (since C may change a lot and changing A is undesirable)
            – Steven
            Jun 13 at 14:18










          • The DHCP response could assign 192.168.4.1 as the default gateway for device C, then you don't have to do anything on device C. You will have to arrange something similar for device A, or at least add a route to 192.168.4.0/24 via device B on the default gateway, if A's default gateway is not B; that gateway will send a redirect ICMP to A when A tries to reach 192.168.4.0/24.
            – wurtel
            Jun 13 at 15:03










          • So both A and C should have their default gateway set to B. But hoe does B 'know' it has to route traffic between the two interfaces? I thought the routing rules are meant to accommodate that. If not, what do routing rules do?
            – Steven
            Jun 13 at 21:49










          • In fact, the current setup has the gateway of A set to 192.168.5.1 and the gateway of C set to 192.168.4.1. From both A and C I can reach ..5.1 and ..4.1 however I cannot reach each other. What is my setup lacking...?
            – Steven
            Jun 14 at 7:36










          • Post the output of ip route show from every station please.
            – Winnie Tigger
            Jun 14 at 8:07










          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%2f449468%2fhow-to-route-between-interfaces%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          No need to use iptables. If you have successfully enabled the ip forwarding, device B will do the job because both networks are directly connected to B. The thing you might missing are the correct routes on device A and C.
          On A:



          ip route add 192.168.4.0/24 via 192.168.5.1


          On C:



          ip route add 192.168.5.0/24 via 192.168.4.1





          share|improve this answer





















          • Ok yes, this worked! However this made me realize that I did not explain my question properly. The question I now have: how can I accomplish this with ONLY changing the settings of device B? (since C may change a lot and changing A is undesirable)
            – Steven
            Jun 13 at 14:18










          • The DHCP response could assign 192.168.4.1 as the default gateway for device C, then you don't have to do anything on device C. You will have to arrange something similar for device A, or at least add a route to 192.168.4.0/24 via device B on the default gateway, if A's default gateway is not B; that gateway will send a redirect ICMP to A when A tries to reach 192.168.4.0/24.
            – wurtel
            Jun 13 at 15:03










          • So both A and C should have their default gateway set to B. But hoe does B 'know' it has to route traffic between the two interfaces? I thought the routing rules are meant to accommodate that. If not, what do routing rules do?
            – Steven
            Jun 13 at 21:49










          • In fact, the current setup has the gateway of A set to 192.168.5.1 and the gateway of C set to 192.168.4.1. From both A and C I can reach ..5.1 and ..4.1 however I cannot reach each other. What is my setup lacking...?
            – Steven
            Jun 14 at 7:36










          • Post the output of ip route show from every station please.
            – Winnie Tigger
            Jun 14 at 8:07














          up vote
          1
          down vote













          No need to use iptables. If you have successfully enabled the ip forwarding, device B will do the job because both networks are directly connected to B. The thing you might missing are the correct routes on device A and C.
          On A:



          ip route add 192.168.4.0/24 via 192.168.5.1


          On C:



          ip route add 192.168.5.0/24 via 192.168.4.1





          share|improve this answer





















          • Ok yes, this worked! However this made me realize that I did not explain my question properly. The question I now have: how can I accomplish this with ONLY changing the settings of device B? (since C may change a lot and changing A is undesirable)
            – Steven
            Jun 13 at 14:18










          • The DHCP response could assign 192.168.4.1 as the default gateway for device C, then you don't have to do anything on device C. You will have to arrange something similar for device A, or at least add a route to 192.168.4.0/24 via device B on the default gateway, if A's default gateway is not B; that gateway will send a redirect ICMP to A when A tries to reach 192.168.4.0/24.
            – wurtel
            Jun 13 at 15:03










          • So both A and C should have their default gateway set to B. But hoe does B 'know' it has to route traffic between the two interfaces? I thought the routing rules are meant to accommodate that. If not, what do routing rules do?
            – Steven
            Jun 13 at 21:49










          • In fact, the current setup has the gateway of A set to 192.168.5.1 and the gateway of C set to 192.168.4.1. From both A and C I can reach ..5.1 and ..4.1 however I cannot reach each other. What is my setup lacking...?
            – Steven
            Jun 14 at 7:36










          • Post the output of ip route show from every station please.
            – Winnie Tigger
            Jun 14 at 8:07












          up vote
          1
          down vote










          up vote
          1
          down vote









          No need to use iptables. If you have successfully enabled the ip forwarding, device B will do the job because both networks are directly connected to B. The thing you might missing are the correct routes on device A and C.
          On A:



          ip route add 192.168.4.0/24 via 192.168.5.1


          On C:



          ip route add 192.168.5.0/24 via 192.168.4.1





          share|improve this answer













          No need to use iptables. If you have successfully enabled the ip forwarding, device B will do the job because both networks are directly connected to B. The thing you might missing are the correct routes on device A and C.
          On A:



          ip route add 192.168.4.0/24 via 192.168.5.1


          On C:



          ip route add 192.168.5.0/24 via 192.168.4.1






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jun 13 at 8:26









          Winnie Tigger

          1595




          1595











          • Ok yes, this worked! However this made me realize that I did not explain my question properly. The question I now have: how can I accomplish this with ONLY changing the settings of device B? (since C may change a lot and changing A is undesirable)
            – Steven
            Jun 13 at 14:18










          • The DHCP response could assign 192.168.4.1 as the default gateway for device C, then you don't have to do anything on device C. You will have to arrange something similar for device A, or at least add a route to 192.168.4.0/24 via device B on the default gateway, if A's default gateway is not B; that gateway will send a redirect ICMP to A when A tries to reach 192.168.4.0/24.
            – wurtel
            Jun 13 at 15:03










          • So both A and C should have their default gateway set to B. But hoe does B 'know' it has to route traffic between the two interfaces? I thought the routing rules are meant to accommodate that. If not, what do routing rules do?
            – Steven
            Jun 13 at 21:49










          • In fact, the current setup has the gateway of A set to 192.168.5.1 and the gateway of C set to 192.168.4.1. From both A and C I can reach ..5.1 and ..4.1 however I cannot reach each other. What is my setup lacking...?
            – Steven
            Jun 14 at 7:36










          • Post the output of ip route show from every station please.
            – Winnie Tigger
            Jun 14 at 8:07
















          • Ok yes, this worked! However this made me realize that I did not explain my question properly. The question I now have: how can I accomplish this with ONLY changing the settings of device B? (since C may change a lot and changing A is undesirable)
            – Steven
            Jun 13 at 14:18










          • The DHCP response could assign 192.168.4.1 as the default gateway for device C, then you don't have to do anything on device C. You will have to arrange something similar for device A, or at least add a route to 192.168.4.0/24 via device B on the default gateway, if A's default gateway is not B; that gateway will send a redirect ICMP to A when A tries to reach 192.168.4.0/24.
            – wurtel
            Jun 13 at 15:03










          • So both A and C should have their default gateway set to B. But hoe does B 'know' it has to route traffic between the two interfaces? I thought the routing rules are meant to accommodate that. If not, what do routing rules do?
            – Steven
            Jun 13 at 21:49










          • In fact, the current setup has the gateway of A set to 192.168.5.1 and the gateway of C set to 192.168.4.1. From both A and C I can reach ..5.1 and ..4.1 however I cannot reach each other. What is my setup lacking...?
            – Steven
            Jun 14 at 7:36










          • Post the output of ip route show from every station please.
            – Winnie Tigger
            Jun 14 at 8:07















          Ok yes, this worked! However this made me realize that I did not explain my question properly. The question I now have: how can I accomplish this with ONLY changing the settings of device B? (since C may change a lot and changing A is undesirable)
          – Steven
          Jun 13 at 14:18




          Ok yes, this worked! However this made me realize that I did not explain my question properly. The question I now have: how can I accomplish this with ONLY changing the settings of device B? (since C may change a lot and changing A is undesirable)
          – Steven
          Jun 13 at 14:18












          The DHCP response could assign 192.168.4.1 as the default gateway for device C, then you don't have to do anything on device C. You will have to arrange something similar for device A, or at least add a route to 192.168.4.0/24 via device B on the default gateway, if A's default gateway is not B; that gateway will send a redirect ICMP to A when A tries to reach 192.168.4.0/24.
          – wurtel
          Jun 13 at 15:03




          The DHCP response could assign 192.168.4.1 as the default gateway for device C, then you don't have to do anything on device C. You will have to arrange something similar for device A, or at least add a route to 192.168.4.0/24 via device B on the default gateway, if A's default gateway is not B; that gateway will send a redirect ICMP to A when A tries to reach 192.168.4.0/24.
          – wurtel
          Jun 13 at 15:03












          So both A and C should have their default gateway set to B. But hoe does B 'know' it has to route traffic between the two interfaces? I thought the routing rules are meant to accommodate that. If not, what do routing rules do?
          – Steven
          Jun 13 at 21:49




          So both A and C should have their default gateway set to B. But hoe does B 'know' it has to route traffic between the two interfaces? I thought the routing rules are meant to accommodate that. If not, what do routing rules do?
          – Steven
          Jun 13 at 21:49












          In fact, the current setup has the gateway of A set to 192.168.5.1 and the gateway of C set to 192.168.4.1. From both A and C I can reach ..5.1 and ..4.1 however I cannot reach each other. What is my setup lacking...?
          – Steven
          Jun 14 at 7:36




          In fact, the current setup has the gateway of A set to 192.168.5.1 and the gateway of C set to 192.168.4.1. From both A and C I can reach ..5.1 and ..4.1 however I cannot reach each other. What is my setup lacking...?
          – Steven
          Jun 14 at 7:36












          Post the output of ip route show from every station please.
          – Winnie Tigger
          Jun 14 at 8:07




          Post the output of ip route show from every station please.
          – Winnie Tigger
          Jun 14 at 8:07












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449468%2fhow-to-route-between-interfaces%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