0

It should go without saying, I'm new and still learning about networking. One of the things I'm not clear on and couldn't find a satisfying answer to, although I've done some digging around, is how devices that are connected to a switch get their IP address and what kind of IP address they are?

What I mean is, from what I've found, switches don't operate at the IP address level, but the MAC Address level.


So the question is:

  1. How do the devices connected to a particular switch get their IP? Who hands it out to them? Do you have to assign it manually or does (I assume) the router hand it out automatically?

  2. Do switches automatically create a sub-net? That is, if I have two switches connected to my router, will the devices connected to those 2 switches be on 2 different subnets? If so, is that the default, or do I have to set it up, and can I change that (ie, make it so that they're actually on the same subnet)?

I know it's more questions than one, but they're all in the bracket of how a switch-connected device is assigned an IP. I'd appreciate it if you could maybe throw some light on this.

1
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
    – Ron Maupin
    Dec 15 '19 at 6:19
4

First when the device boots up, it will try to look for a DHCP server. It will send a broadcast traffic ("Who is the DHCP server?") and the corresponding DHCP server will respond to the request, in your case the Router is your DHCP server.

If no DHCP server in the network, the host for example windows, will automatically assign a unique class B ip address 169.254.0.0 to 169.254.255.255 (APIPA).

3

There are two ways:

  • You manually (statically) configure each device with an IP, a subnet mask, a default gateway and a DNS server. If you have 20 devices, you do it 20 times.
  • The device is auto configured by a DHCP server. You need to configure the DHCP server once, no matter how many devices will use it (except if the number of devices is greater than the number of IPs the server can lease).

In your case, when you plug your device to a switch and get an IP, that means your switch is a DHCP server, or is connected to a DHCP server.

For IPv6, things are slightly different but I would highly recommend being familiar with IPv4 DHCP before learning it.

1
  • There's actually a third way: Zeroconf aka APIPA from the (unroutable) 169.254.0.0/16 range.
    – Zac67
    Dec 26 '19 at 17:10
0

To answer the second part of your question:

As you point out, switches operate at layer 2 (MAC level) so IP addresses and subnets mean nothing to them. If your switches are connected to different interfaces on your router, then they are usually on different subnets, but that configuration is done on the router, not the switches.

If you edit your post to include the device configurations and a diagram of what you're trying to do, we can help you get everything configured.

0

No device can get it's IP address automatically even when it's connected to switch. The DHCP server assigns each device it's IP which is generally configured on your router.

If DHCP is not configured one has to assign each device it's IP manually.

IPs and subnets are no value to a switch. Its function is to only forward network traffic to the concerned host.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.