Create a second network on same physical LAN?

7

2

I have a LAN at home using the subnetwork 192.168.1.0/24. I know this subnet mask supports 254 hosts.

Two Questions:

  1. How can I create a subnetwork like 192.168.2.0/24 on the same physical network?
  2. Would a host on the 192.168.2.0/24 network be able to access the Internet if I pointed its default gateway to my router's IP address of 192.168.1.1?

Cuhrazy

Posted 2014-11-28T16:25:13.307

Reputation: 71

1I propose this question is different from the marked duplicate. The duplicate specifies that devices on the second subnet not have access to the first network, but this question wants devices on the same physical network. This difference is significant as is constrains answers to the other Q to physically separate the networks which is the opposite of what this asker wants. – I say Reinstate Monica – 2018-09-15T11:50:00.467

Note that two different subnetworks on the same physical segment are discouraged, because layer 2 broadcasts won't match layer 3, which will only lead to headaches in your network setup. If you want different subnetworks on the same physical segments, consider using VLAN. – dirkt – 2018-09-16T10:32:23.987

@dirkt Can you share some examples of what you have in mind? – I say Reinstate Monica – 2018-09-16T13:54:51.653

@TwistyImpersonator: What kind of examples? VLAN, how to create an adapter depends on the OS (e.g. ip add link eth0 name eth0.5 type vlan id 5 on Linux).

– dirkt – 2018-09-16T16:22:05.927

@dirkt sorry I wasn't clear. Examples of layer 2 broadcasts causing problems because of using two IP subnetworks on the same physical link. – I say Reinstate Monica – 2018-09-16T16:23:30.463

@TwistyImpersonator: For example, try doing DHCP. ARP with identical MACs can also cause confusion. And having multiple IPv4 addresses on the same interface also causes headaches (depending on the OS), if you are not careful, e.g. one connection can bind to both and half the packets will be dropped, coming from the wrong source address. – dirkt – 2018-09-16T16:26:34.040

@dirkt DHCP assigns addresses and won't break if other L3 addresses are in use on the link (using DHCP to assign addresses from distinct subnets would require careful config, but there's nothing inherently wrong with doing so). I can't think of a scenario where ARP would break anything by reporting that a single MAC owns multiple L3 addresses (other than confusing an uninformed admin watching a packet sniffer). And if an OS can't keep it's connection mappings straight, I'm inclined to observe that's just bad implementation, not an indication that any networking principles have been violated. – I say Reinstate Monica – 2018-09-16T16:48:20.083

Answers

10

Question #1:
How can I create a subnetwork like 192.168.2.0/24 on the same physical network?

You can create a separate subnetwork alongside your existing LAN network simply by configuring hosts on the second network using IP addresses from the 192.168.2.0/24 subnet.

For example:

Existing Subnetwork "A" (using 255.255.255.0 mask):

Router: 192.168.1.1
Computer 1: 192.168.1.2
Computer 2: 192.168.1.3

New Subnetwork "B" (using 255.255.255.0 mask):

Computer 3: 192.168.2.2
Computer 4: 192.168.2.3

Let's assume you configure all of the hosts in this example to use the router's IP address 192.168.1.1 as their default gateway. The hosts on subnetwork A will have Internet access, but those on subnetwork B will not. That's where you next question comes into play:

Question #2:
Would a host on the 192.168.2.0/24 network be able to access the Internet if I pointed its default gateway to my router's IP address of 192.168.1.1?

Your router's internal IP address is 192.168.1.1. This address places it on subnetwork A but makes it inaccessible to hosts on subnetwork B. In short, this is because a host can only communicate directly with another host on the same subnet. Subnet B hosts can send packets to any host that has an IP address of 192.168.2.0 through 192.168.2.255 (assuming our 24 bit mask). Because the router's IP address doesn't fall in this range, it's inaccessible to subnet B.

The solution is to use a real router (I'm assuming your router is actually a gateway). A true router has multiple interfaces and thus connects to multiple subnetworks to route traffic between them. So in your case, your router would have two internal IP addresses:

  • 192.168.1.1 for subnetwork A
  • 192.168.2.1 for subnetwork B

Hosts on each subnetwork would use the respective IP address as their default gateway. When the host 192.168.2.3 tries to talk to host 192.168.1.3 it would send the traffic to the router which would "route" the packets between the two subnets. Traffic destined for the Internet works the same way. Since an Internet site's IP address isn't on the local subnetwork, the host sends the packets to the router which forwards them on to the Internet.

For a detailed explanation of IPv4 subnetting, check out this question on ServerFault.

I say Reinstate Monica

Posted 2014-11-28T16:25:13.307

Reputation: 21 477