Just trying to assess whether this is actually possible before I get stuck in! Does anyone know if it is possible to set the Arduino to have multiple IP addresses. So that for instance I could communicate between two different subnets such as -
192.168.1.2 (PC) <---> 192.168.1.177 (arduino) <----> 192.168.0.1(device on different subnet)
I realise that using teh built in libraries it may not be possible to do the above and that the packet headers will likely need modifying to allow this to work! In some senses the device would be acting a little like a router but I would not need the majority of functions that most routers support!
Would this work for addresses with substantially different subnets,
e.g. 192.168.1.x subnet = 255.255.255.0
10.10.1.x subnet = 255.0.0.0
Would communication be possible between the arduino shield with a 192 address and the 10.x.x.x address just by having a subnet covering any possible address? I was under the impression that usually when communicating without a router the IP addresses had to be within the same range to communicate ?
i.e. 192.168.1.3 ---> 192.168.1.2 = OK
but 192.168.1.3 ---> 10.10.1.3 = FAIL
It would be unusual (not unheard of or impossible) to have a local network with addresses in more than one subnet. On a "real" computer, just about anything is possible with a combination of addresses and masks. But of course everyone has to be playing by the same rules. In other words, you can make it so that your 192.168.1.x device can send to a 10.10.10.x device, but the other side also has to know that 192.168.1 is local as well. What's the situation you're trying to deal with?
If you can tell all the relevant devices that all of 192.168 is local, then you may be fine.
Thanks for your reply, it is indeed an "unusual" network configuration that I have proposed. Basically I need to use the arduino as a sort of proxy interface to access and configure another device which has an IP on a different subnet to the arduino/pc (but all devices are local). In order to do this the arduino needs to be able to communicate with a standard 192.168.1.x standard private IP address to a 10.10 address!
Noting that he PC will be accessing the arduino to configure the device on a different subnet. If I could use a pc instead of say an arduino this would be simple as you can configure a pc to have multiple IP addresses and subnets for the same adaptor, with the arduino however, I am not really sure if it is possible..
Does it have to be Arduino? There are lots of routers you can buy for short $$ (eBay especially...) and run a flavor of Linux on...
I think you're way outside of the mainstream with the Arduino ethernet shield. OTOH, some of the cheaper ethernet shields require lower level code to interface with them. With those, you might be able to roll your own packets, etc.
Well it has to be a small device that doesn't use up too much in terms of power/space! I had thought that some sort of router would be a much more suitable candidate but I believe that these devices will be harder to program because most were not designed to be hacked...
It should be possible to re-program some of the Ethernet libs to re-write some packets, the question is will it be worth the time spent compared to the alternatives...
I'd really recommend you look at, for instance, dd-wrt (or <insert.your.favorite.alternative.router.firmware.name>) as a possibility. The devices may not have been made precisely with the intent of hacking, but they are quite hacker friendly, and there is a huge support community. Older Linksys routers are often available on eBay for around the price of an arduino. They may use more power, but not tons more.
I can't personally help you with trying to muck with the guts of IP packets via the ethernet shield. But if you program a mask of 0.0.0.0 on the shield, it should consider all addresses local, which should allow you to send to anything local. However, the other side (10.x.y.z) would have to be told that the 192.168.x network is local via its routing table.
You might also try an approach where you:
initialize the interface on net 1
receive from computer on net 1
tear down interface on net 1
initialize the interface on net 2
send to computer on net 2
tear down interface on net 2
back to top...
Such an approach is probably not practical if you have to connect via TCP, but if it's UDP, it might work.
Right ok, thanks for your help! I had the impression that re-writing IP packets was not going to be something that was done often! Thanks anyway, I had thought of possibly using two arduino with an ethernet shield but I think this would probably be overkill and still pose problems of its own!
Rest assured, there are others here who know loads more than I do. I'm not sure if you mean two arduinos, each with an ethernet shield (with some comm link between them) or if you mean one arduino with two ethernet shields. I seem to remember such a discussion coming up recently. If possible, it would probably involve cutting some traces and soldering some wires to alternative pins, and a second copy of the library, modified to support the secondary pin assignments. It at least sounds conceivable to me, but I don't really know if it's feasible.
Hopefully, someone smarter and with more experience can chime in...