Will computers connected to a switch have a different ip?

10,899

Solution 1

If your switch does offer DHCP, then it needs to be configured properly if you want it to give out leases for 192.168.0.0/24.

The IP assigned to your switch can be without any relation to the DHCP range, which the switch might offer.

However, in your setup it is more likely that the router is acting a as DHCP server and the switch will thus just do typical layer 2 tasks and forward your packets.

Solution 2

You have three separate issues here. First, assigning unique IP addresses to Computer 1 and Computer 2 in the LAN (the right side of your diagram). If the router implements a DHCP server, and the switch is just a transparent switch, then the different computers will be served different IP addresses. This is how routers usually work, so you should be fine.

Second, doing port forwarding on traffic coming into the router from the WAN (the left edge of your diagram). Again, most routers implement network address translation (NAT), so the multiple IP addresses on the LAN appear as only one IP address to the WAN. This means that incoming connection requests will generally be refused, as there's no way for the router to know which LAN IP address to route the request to. If the router supports port forwarding, then you can configure it to route connection requests to a specific external port to a specific port on a specific internal IP address. For example, you could have incoming port 80 requests be routed to computer 1's web server, and incoming port 22 requests routed to computer 2's ssh daemon.

Third, what happens when one of the computers is turned off for a few days, and then turned back on? The DHCP server may issue a different IP address for that computer, breaking your port forwarding configuration. To solve this, many routers support "static DHCP", where they always issue a specific IP address to a specific computer (identified by its MAC address).

So: you need DHCP, port forwarding, and static DHCP to do what you seem to want to do.

Share:
10,899

Related videos on Youtube

Grammargeek
Author by

Grammargeek

Updated on September 18, 2022

Comments

  • Grammargeek
    Grammargeek over 1 year

    I want to set up a network switch with several servers connected to it that must be port forwarded.

    Please refer to the below diagram for my setup:

                    ___Computer 2
                    |
    Router-->Switch-|
                    |__Computer 1
    

    So my question to you is this:

    If my router assigns IP's as 192.168.0.x will computer 1 and computer 2 have two seperate IP addresses following the 192.168.0.x format?

  • Grammargeek
    Grammargeek almost 9 years
    How do I find out if it supports DHCP? (I havent bought it yet I'm still figuring out if it's the best option)
  • Grammargeek
    Grammargeek almost 9 years
    So, I have a question, uf it's doing this will it act as though I just had a bunch of extra ports on my router?
  • Michael Bailey
    Michael Bailey almost 9 years
    Basically yes. Relatively securely as opposed to a hub.
  • Grammargeek
    Grammargeek almost 9 years
    Okay then, that was basically what I needed to know, thanks!
  • Daniel Griscom
    Daniel Griscom almost 9 years
    You mentioned that you wanted the switch to assign IP addresses; that's what static DHCP is for.
  • Grammargeek
    Grammargeek almost 9 years
    I simply meant that I want computer 1's ip to be different from computer 2's ip
  • Michael Bailey
    Michael Bailey almost 9 years
    That is very different. You can statically assign one with .1 and one with .2 if you want.
  • davidgo
    davidgo almost 9 years
    Virtually no switches will offer DHCP - this is typically done by the router.
  • peterh
    peterh almost 9 years
    Unfortunately, it seems the reviewers consider your question off-topic here. In similar cases I would suggest to try superuser.com or networkengineering.stackexchange.com , where it would be considered probably ontopic.