DHCP And Switch

Consider this following topology

Pasted image 20241027213653.png

Components:

  • Switch1: L2 Ethernet switch
  • Switch2: L2 Ethernet switch
  • R1: Cisco 3660

Pasted image 20241027213708.png

[!important]
We pause interconnection between Switch 1 and Switch 2

First the PC1 and 2 will not have IP. First think we need to do is to assign an IP.

In order to do this, R1 need to setup DHCP server and also interconnect Switch 1 and Switch 2 and assign its subnet.

R1:

  1. Get a list of possible interface show ip int
  2. Plug in switch 1 to (FastEthernet 0/0) fe0/0
  3. Plug in switch 2 to fe0/1
  4. Go to configure terminal config t
  5. Select interface fe0/0: int FastEthernet 0/0
    1. Assign IP address and netmask for switch 1 ip address 9.9.9.1 255.255.255.0
    2. Enable the interface (bring state to up, by default it's down) no shutdown
    3. Exit out of configuration for fe0/0: exit
  6. Select interface fe0/1: int FastEthernet 0/1
    1. Assign ip address ip address 9.9.8.1 255.255.255.0
    2. Enable interface no shutdown
    3. Exit out of configuration: exit
  7. Save all config to switch for the next run: write memory
  8. Confirm all setting up correctly: show ip interface brief

As the result, we have assigned ip for the two interface port. Next we want to setup DHCP server

R1:

  1. Go to config term: config t
  2. List out current dhcp pool (expect empty result) show ip dhcp
  3. Create new pool default: ip dhcp pool default
  4. Setup default router: default-router 9.9.9.1.
    1. Note, this will automatically matches with the subnet created above. As a result, this will assign Switch 1 as default router
    2. End the configuration: end
  5. Confirm again with show ip dhcp pool

Now technically we can do ip dhcp on each machine to obtain an IP address

PC1:

  1. ip dhcp (this will assign 9.9.9.2) since the default dhcp is 9.9.9.1

PC2:

  1. ip dhcp (this will assign 9.9.9.3) since the default dhcp is 9.9.9.1

Why would PC2 has 9.9.9.3 whereas it's in the 9.9.8.1/24 subnet?

  • Since we dont setup a broadcast domain, PC2 will send a DHCP discover request to the network. This is typically a broadcast.
  • The broadcast will then transfer to Switch 2 and subsequently R1.
  • R1 will broadcast again to fe0/0 which is the default DHCP
  • This is where the ip was assigned

To fix this, release DHCP from PC2: ip dhcp -x

Setup another DHCP pool for fe0/1:
R1:

  1. Go to config term: config t
  2. List out current dhcp pool (expect empty result) show ip dhcp
  3. Create new pool default: ip dhcp pool default-b
  4. Setup default router: default-router 9.9.8.1.
    1. Note, this will automatically matches with the subnet created above. As a result, this will assign Switch 2 as default router
    2. End the configuration: end
  5. Confirm again with show ip dhcp pool

Redo DHCP on PC2: ip dhcp

Now PC2 will be assigend 9.9.8.2

Test ping from PC1 to PC2 and vice versa should be success.

Note: the arp table for some reasons was stored in the router not the PC. This might be the behavior of VPC (Virtual Computer from GNS3)