10

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?
7
  • 1
    I 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. Sep 15, 2018 at 11:50
  • 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
    Sep 16, 2018 at 10:32
  • @dirkt Can you share some examples of what you have in mind? Sep 16, 2018 at 13:54
  • @TwistyImpersonator: What kind of examples? [VLAN]( en.wikipedia.org/wiki/Virtual_LAN), 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
    Sep 16, 2018 at 16:22
  • @dirkt sorry I wasn't clear. Examples of layer 2 broadcasts causing problems because of using two IP subnetworks on the same physical link. Sep 16, 2018 at 16:23

1 Answer 1

13

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.

1
  • When you say real router, do you mean a physical router device? Does this need some special router? (at least 3 NIC cards?)
    – doraemon
    Dec 2, 2021 at 14:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .