bxm's IT Story

DHCP Relay Agent (DHCP의 끝판왕) 본문

Network/Cisco (KEDU)

DHCP Relay Agent (DHCP의 끝판왕)

bxmsta9ram 2021. 6. 28. 11:54

## Broadcast는 Router를 넘어가지 않음. 

## 그래서 PC3에서 "여기 IP좀 주세요~!" 해도 SW1 까지 넘어가지 않음.

## DHCP 끝판왕 실습을 해보자.

 

## 나중에 혼자 실습해볼때는 Port1의 IP를 28.28.12.0 /30 대역에서 --> 1.1.12.0 /30 대역으로 바꿔서하자.

    아래 코드들 쓰다보니까 헷갈림.


공통]

ena

conf t

no ip domain lookup

line c 0

logg sy

exec-timeout 0

line vty 0 4

pass cisco

exit

 

ali exec c conf t

ali exec r sh run

ali exec b sh ip int b

ali exec i sh ip route

 

 


SW1]

conf t

ip routing

vlan 10

  exit

vlan 20

  exit

vlan 12

  exit

 

int f1/1

  sw mo ac

  sw ac vlan 10

  exit

 

int f1/2

  sw mo ac

  sw ac vlan 20

  exit

 

int range f1/5 - 6

  sw tr enc dot

  sw mo tr

  channel-group 1 mo on

  end


SW2]

conf t

ip routing

vlan 30

  exit

vlan 40

  exit

vlan 12

  exit

 

int f1/3

  sw mo ac

  sw ac vlan 30

  exit

 

int f1/4

  sw mo ac

  sw ac vlan 40

  exit

 

int range f1/5 - 6

  sw tr enc dot

  sw mo tr

  channel-group 1 mo on

  end


## SVI를 만들어 Static을 잡아보자 ##

SW1]

conf t

int vlan 12

  ip add 28.28.12.1 255.255.255.252

  exit


SW2]

conf t

int vlan 12

  ip add 28.28.12.2 255.255.255.252

  exit


SW1]

ip route 28.28.30.0 255.255.255.0 vlan 12 28.28.12.2

ip route 28.28.40.0 255.255.255.0 vlan 12 28.28.12.2


SW2]

ip route 28.28.10.0 255.255.255.0 vlan 12 28.28.12.1

ip route 28.28.20.0 255.255.255.0 vlan 12 28.28.12.1


SW1]

int vlan 10

  ip add 28.28.10.254 255.255.255.0

  exit

 

int vlan 20

  ip add 28.28.20.254 255.255.255.0

  end


SW2]

int vlan 30

  ip add 28.28.30.254 255.255.255.0

  exit

 

int vlan 40

  ip add 28.28.40.254 255.255.255.0

  end

## 과연 이러한 상태에서 IP 하나만 주세요! 했을때 넘어갈지 안넘어갈지 봐보기


 

SW1]

conf t

ip dhcp pool NET10

  network 28.28.10.0 /24

  default-router 20.20.10.254

  dns-server 168.126.63.1 8.8.8.8

  lease 10

  class VLAN10

    add range 28.28.10.1 28.28.10.253

    ## 전 장에서 했던 IP 할당 범위! 28.28.30.(1~253)

    exit

 

ip dhcp pool NET20

  network 28.28.20.0 /24

  default-router 20.20.20.254

  dns-server 168.126.63.1 8.8.8.8

  lease 10

  class VLAN20

    add range 28.28.20.1 28.28.20.253

    exit

 

ip dhcp pool NET30

  network 28.28.30.0 /24

  default-router 28.28.30.254

  dns-server 168.126.63.1 8.8.8.8

  lease 10

  class VLAN30

    address range 28.28.30.1 28.28.30.253

    exit

 

ip dhcp pool NET40

  network 28.28.40.0 /24

  default-router 28.28.40.254

  dns-server 168.126.63.1 8.8.8.8

  lease 10

  class VLAN40

    address range 28.28.40.1 28.28.40.253

    end


SW2] == 이 부분 정보기기 운용기능사 실기에 그대로 나옴.

conf t

int vlan 30

  ip dhcp client class-id VLAN30

  ip helper-address 28.28.12.1

  exit

  ## 왜 해주냐면, PC3이 "거기 누구 없어요!!" Broadcast를 보내면 SW2의 f1/3이 Broadcast port이므로

      Broadcast가 못넘어감. 그래서 SW2가 Broadcast를 Unicast로 바꿈. 그러면 SW1이 DHCP Server이므로

      Unicast를 받고 알아서 접수를 함.

      - helper-address <서버주소>

     

  ##DHCP Relay Agent는 Client로부터 discover와 request(discover와 request는 Broadcast)가 도착하면 unicast로

     바꿔서 Router 건너편으로 전달한다. 고로, 라우터 건너서도 DHCP로 IP를 부여받을 수 있다.

 

int vlan 40

  ip dhcp client class-id VLAN40

  ip helper-address 28.28.12.1

  end


PC3]

conf t

no ip routing

int f0/0

  sh

  no sh

  ip add dhcp

IP 28.28.30.4를 할당받았다!


PC4]

conf t

no ip routing

int f0/0

  sh

  no sh

  ip add dhcp

IP 28.28.40.1을 할당받았다!