-1

I have a scenario where i have 4 modems connected to a switch. all four modems have IP address 192.168.0.1(default). i want to connect all of these four modems with a single switch in a way that i should be able to access each of modem from my machine like modem1(10.0.0.1), modem2(10.0.0.2), modem3(10.0.0.3) and modem4(10.0.0.4). To me it is more like NATing with VLAN on switch. Please advise how can i create such a network with switch required to do this?

This is what i want:
Modem1(192.168.0.1) => SwitchPort1 => 10.0.0.1
Modem2(192.168.0.1) => SwitchPort2 => 10.0.0.2
Modem3(192.168.0.1) => SwitchPort3 => 10.0.0.3
Modem4(192.168.0.1) => SwitchPort4 => 10.0.0.4

Let me tell you context i have 100 modems that needs firmware upgrade, i already have software that can upgrade a modem's firmware in 5 minutes in an automated way(plug-upload), but upgrading 100 modems = 5 min*100 = 1 whole working day. i was looking for a way to make it do able in 1-2 hours. so changing IPs of 100 modems will not work for me :)

2 Answers2

1

In short, you can't. You need to either change the IP on three of the modems, or you need to have intervening networks between the switch and the modems that make the NATs you put in place work. You cannot have multiple devices with the same IP on the same network.

John
  • 9,070
  • 1
  • 29
  • 34
  • Thanks @John, yes i know we normally can't due to ARP broadcast/IP conflict but i was thinking of some switch that can offer VLAN on each port and then can offer NAT on each port. Is there any cheap solution doing that? i don't mind if we have to put a router in between modems/switch or switch/computer – Shoaib Shaikh Nov 20 '13 at 12:51
  • If you put a router in between the switch and each modem, you don't need to use VLANs. That router can be a regular router or a computer with two ethernet interfaces or whatever you wish, but there must be four distinct items - not one item connected to all four switch ports. The cheapest solution is to simply change the IP of three of the modems. – John Nov 20 '13 at 12:58
  • ok, so i would have to add a router in between and connect my models to router and then my router will perform NAT of these modems? – Shoaib Shaikh Nov 20 '13 at 13:02
  • No, you need FOUR routers. One for each modem. Seriously, just CHANGE THE IP ADDRESS ON YOUR MODEMS. – John Nov 20 '13 at 13:06
  • I understand changing modem IPs is the cheapest way. let me tell you context i have 100 modems that needs firmware upgrade, i already have software that can upgrade a modem's firmware in 5 minutes in an automated way(plug-upload), but upgrading 100 modems = 5 min*100 = 1 whole working day. i was looking for a way to may it do able in 1-2 hours. so changing IPs of 100 modems will not work for me :) – Shoaib Shaikh Nov 20 '13 at 13:22
  • 1
    1 working day versus 2 weeks to implement a VLAN solution? Versus 1 week to change the IPs which will save you 4 minutes * 100 on future upgrades? Seriously... change the IPs. – John Nov 20 '13 at 13:24
  • :) i take you on this. things are pretty much clear now. Thanks – Shoaib Shaikh Nov 20 '13 at 13:25
1

If the switch supports VLANs, and you're willing to have a router proxy the traffic, then I suspect that it can be done.

Each modem will need to be on a VLAN, and the router will need to have presence on all four of those VLANs. For the sake of illustration, let's assume that

  1. Modem 1 is on VLAN 11, modem 2 is on VLAN 12, and so on;

  2. The router is a Linux box, and is on a port that support VLAN tagging, where all the modem VLANs are present, and in addition another VLAN on some third network, facing the clients, which isn't 10.0.0.0/16, and which we will call VLAN 99;

  3. The clients will all need static routes to send traffic to 10.0.0.0/16 addresses via the address assigned to eth0.99;

  4. The modems are accessed by the clients on addresses which are all on different subnets of 10.0.0.0, let's say modem 1 will be accessed as if it were 10.0.1.2/24, modem 2 as 10.0.2.2/24, and so on;

  5. Each of the modem-facing VLAN interfaces has an address on the corresponding 10.0.0.0 subnetwork. Let's assume that on port eth0.11, which is VLAN 11, talking to modem 1, the address is 10.0.1.1/24, 10.0.2.1/24 on eth0.12, and so on for eth0.13, and eth0.14;

  6. In addition, each modem-facing VLAN will need an alias on the 192.168.0.0/24 network, and life will be simpler if this is different in each case; let's assume it's 192.168.0.11/24 on eth0.11, 192.168.0.12/24 on eth0.12, and so on;

For each interface, you'll need a couple of lines like

iptables -t nat -A OUTPUT -o eth0.11 -d 10.0.1.2 -j DNAT --to-destination 192.168.1.1
iptables -t nat -A POSTROUTING -o eth0.11 -j SNAT --to-source 192.168.0.11

But I stress that the above is theoretical; I can't see why it wouldn't work, but I haven't done anything quite like it. I echo John's advice that you'd be much better off reconfiguring your modems.

MadHatter
  • 79,770
  • 20
  • 184
  • 232
  • Thanks @MadHatter, so it looks like this is possible with the help of VLANs for each modem. I also understand john's advice but in my case this is not possible, i just shared the context in a comment above. – Shoaib Shaikh Nov 20 '13 at 13:24