I have a Raspberry-Pi set up as a router which routes traffic between two networks 192.168.1.x
and 192.168.2.x
.
For reasons which are imposed on me by the physical network topology in my house, I want to add a new network interface (easily done with a USB to ethernet adapter) and assign it an IP which is on the same network as one of the other existing interfaces. It would look something like this.
- WAN connection to interface A with IP
192.168.1.100
- LAN connection to interface B with IP
192.168.2.254
(existing) - New interface C with IP
192.168.2.253
Is this even possible?
If it is possible, then I assume having two different interfaces on the same device with the same IP is impossible? This is really the ideal situation. (A)
In other words, I am assuming it is impossible to have the following:
- New interface C with IP
192.168.2.254
(same IP as interface B)
You might notice that (A) is describing a switch. I could put a switch in but it will only connect 3 physical cables together. It seems a bit messy / wasteful, although I conceed this is the trivial solution.
#Why do I want to do this? (TL;DR section)
The internet to my house comes via a regular ISP router. Since this thing does not handle static routes, and I want to run multiple servers on different networks, I have all the traffic from this device routed to a Raspberry-Pi which serves as a low power router, where I can set things such as static routes. Since it is low power it isn't a problem being on 24/7. The router and the Pi sit in a cupboard, downstairs.
In this cupboard there is also a number-crunching machine. It runs hot and so I turn it off when not in use. It has to be in this cupboard, because the heat generated is used to warm the house. I can't put it in my own room, because it is too loud / hot / makes sleeping impossible. So it has to stay in the cupboard. The catch is that this machine has to be on a seperate network to prevent the amount of traffic I produce from slowing down general internet access for everyone else. The other catch is that there are only two physical network cables between the cupboard and my own room - which is somewhat a luxury even. I can't put any more cables in. It will make people angry.
The next catch is that there is another computer, which serves as a NAS. It cannot fit in the cupboard, because there is no room. It is silent, and runs a 25 W TDP chip so it can live in my room.
The NAS has to be available to other users of the network, so it has to be on the "general users" network. (Same network as the LAN side of the Pi router.) Since it runs Free NAS it can (probably) be made to route traffic to a new network for my own personal use.
So one of those cables is used moving data up to the NAS box, the other is used moving data on my own seperate network down to the number cruncher.
Weird, but that's how it is.
man ip ip-route
. Each NIC can have its own IP address, and "packet routing" is how the system decides which one to use, for each outgoing packet. – waltinator Sep 24 '20 at 23:26