I have two units (a computer and a nas) connected to the same switch, both with external ips. Why are connections between them routed through the external gateway? Shouldn't the switch route them directly?
2 Answers
What are the IP addresses and netmasks? Are both hosts in the same subnet? Are the machines dual-homed
A switch does not route, it forwards packets. If the IP of one of the client interfaces is on the same IP as the IP of the NAS interface that you used to connect, then it should not touch your router/gateway. If your devices have multiple addresses you could be using an address that is not common to both hosts forcing it to go through the router. If the 2 hosts are not on the same subnet then the traffic will have to go through the router.
-
Not dual-homed. The IPs are: pc x.x.103.233 nas x.x.102.69 gateway x.x.102.1 mask 255.255.254.0 (same gateway and mask on both)– henrikFeb 28, 2011 at 9:03
-
How do you know they are being routed? Can you post the logs/captures? If you ping the NAS from your client what MAC address shows up for the NAS IP in your ARP table. The MAC of the NAS, or your router. Feb 28, 2011 at 9:28
-
The nas and the gateway share the same mac in the arp table. And it's not my router. It's my isp's gateway if that makes a difference. more info in my reply to dbasnett. To be honest I don't KNOW how it's routed but the speed suggests it. That and a trace root.– henrikFeb 28, 2011 at 10:07
-
Ok the switch routes based on the MAC and the ISP gateway gives its own MAC. Is there any way to work around this? Setting fixed entries in the arp table? Not great but could it work?– henrikFeb 28, 2011 at 11:44
-
1Looks like a static entry in the arp-table did the trick. While the nas retains it's ip at least.– henrikMar 3, 2011 at 20:43
Assuming that the external gateway is a router and you have a setup like this
-------
-------- | S |
| PC |---------| W | ---------
-------- | I | | |
| T |----| Router |---> Internet
-------- | C | | |
| NAS |---------| H | ---------
-------- | |
-------
the pc, nas, and router interface facing the switch will all need to be on the same subnet. When you say external IPs do you mean public IPs?
-
You assume correctly, or close enough, the router is a gateway belonging to my ISP. They are on the same subnet (look in my reply to Zoredache) and yes I mean that the IP's are public, supplied by the DHCP of my ISP.– henrikFeb 28, 2011 at 9:08