How to route between interfaces
Clash 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
networking network-interface routing
add a comment |Â
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
networking network-interface routing
add a comment |Â
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
networking network-interface routing
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
networking network-interface routing
edited Jun 13 at 14:19
asked Jun 13 at 8:09
Steven
213
213
add a comment |Â
add a comment |Â
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
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 to192.168.5.1
and the gateway of C set to192.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 ofip route show
from every station please.
â Winnie Tigger
Jun 14 at 8:07
 |Â
show 1 more comment
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
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 to192.168.5.1
and the gateway of C set to192.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 ofip route show
from every station please.
â Winnie Tigger
Jun 14 at 8:07
 |Â
show 1 more comment
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
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 to192.168.5.1
and the gateway of C set to192.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 ofip route show
from every station please.
â Winnie Tigger
Jun 14 at 8:07
 |Â
show 1 more comment
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
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
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 to192.168.5.1
and the gateway of C set to192.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 ofip route show
from every station please.
â Winnie Tigger
Jun 14 at 8:07
 |Â
show 1 more comment
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 to192.168.5.1
and the gateway of C set to192.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 ofip 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
 |Â
show 1 more comment
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password