概要

Ciscoルータ(Cisco IOS)でDHCPリレーエージェントを有効にします。これにより、1台のDHCPサーバで複数ネットワークのDHCPクライアントをサポートできるようにします。

ネットワーク構成

図 DHCPリレーエージェントの設定例[Cisco]
図 DHCPリレーエージェントの設定例[Cisco]

設定条件

  • DHCP-Serverに必要なDHCPプールを作成します。DNSサーバとドメイン名は共通です。DNSサーバ「8.8.8.8」 ドメイン名「n-study.com」
  • CL1/CL2/CL3のIPアドレスをDHCPで自動設定します。
  • R1でDHCPクライアントからのDHCPメッセージをDHCP-Serverへ転送できるようにします。

初期設定

R1/DHCP-Serverの初期設定の抜粋です。CL1/CL2/CL3はホスト名のみ設定しています。

R1 設定抜粋(Click)

hostname R1
!
interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
 ip helper-address 192.168.4.100
!
interface Ethernet0/1
 ip address 192.168.2.1 255.255.255.0
!
interface Ethernet0/2
 ip address 192.168.3.1 255.255.255.0
!
interface Ethernet0/3
 ip address 192.168.4.1 255.255.255.0

DHCP-Server 設定抜粋(Click)

hostname DHCP-Server
!
interface Ethernet0/0
 ip address 192.168.4.100 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 192.168.4.1

設定と確認

Step1:DHCPサーバの設定

DHCP-Serverで192.168.1.0/24、192.168.2.0/24、192.168.3.0/24上のDHCPクライアントにIPアドレスを配布できるように以下のDHCPプールを作成します。

プール名ネットワークアドレスデフォルトゲートウェイ
192.168.1.0192.168.1.0/24192.168.1.1
192.168.2.0192.168.2.0/24192.168.2.1
192.168.3.0192.168.3.0/24192.168.3.1

また、DNSサーバのIPアドレスとドメイン名を配布するためのDHCPプールを作成します。

プール名ネットワークアドレスDNSサーバドメイン名
DNS_DOMAIN192.168.0.0/168.8.8.8n-study.com

DHCP-Server DHCPプールの設定

ip dhcp pool 192.168.1.0
 network 192.168.1.0 255.255.255.0
 default-router 192.168.1.1
!
ip dhcp pool 192.168.2.0
 network 192.168.2.0 255.255.255.0
 default-router 192.168.2.1
!
ip dhcp pool 192.168.3.0
 network 192.168.3.0 255.255.255.0
 default-router 192.168.3.1
!
ip dhcp pool DNS_DOMAIN
 network 192.168.0.0 255.255.0.0
 domain-name n-study.com
 dns-server 8.8.8.8

Step2:DHCPクライアントの設定

CL1/CL2/CL3のEthernet0/0のIPアドレスをDHCPで自動設定するようにします。

CL1/CL2/CL3 DHCPクライアント

interface Ethernet0/0
 ip address dhcp

CL1/CL2/CL3とDHCP-Serverは同一ネットワークではありません。そのため、DHCP-ServerはCL1/CL2/CL3にTCP/IP設定情報を配布できません。

Step3:R1 DHCPリレーエージェントの設定

R1をDHCPリレーエージェントとして設定して、CL1/CL2/CL3からブロードキャストのDHCPメッセージをDHCP-Serverへ転送できるようにします。CL1/CL2/CL3が接続されているインタフェースでip helper-addressコマンドで転送先のDHCP-ServerのIPアドレスを指定します。

R1 DHCPリレーエージェントの設定

interface Ethernet0/0
 ip helper-address 192.168.4.100
!
interface Ethernet0/1
 ip helper-address 192.168.4.100
!
interface Ethernet0/2
 ip helper-address 192.168.4.100

Step4:DHCPの確認

CL1/CL2/CL3のIPアドレスを確認します。

DHCPの確認 クライアント

CL1#show ip interface brief | include DHCP
Ethernet0/0                192.168.1.3     YES DHCP   up                    up
CL2#show ip interface brief | include DHCP
Ethernet0/0                192.168.2.2     YES DHCP   up                    up
CL3#show ip interface brief | include DHCP
Ethernet0/0                192.168.3.2     YES DHCP   up                    up

CL1/CL2/CL3はDHCPでIPアドレスを取得していることがわかります。

また、DHCP-Serverでクライアントに割り当てているIPアドレスを確認します。

DHCPの確認 サーバ

DHCP-Server#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address          Client-ID/              Lease expiration        Type
                    Hardware address/
                    User name
192.168.1.2         0063.6973.636f.2d61.    Nov 05 2022 04:49 AM    Automatic
                    6162.622e.6363.3030.
                    2e30.3230.302d.4574.
                    302f.30
192.168.2.2         0063.6973.636f.2d61.    Nov 05 2022 04:19 AM    Automatic
                    6162.622e.6363.3030.
                    2e30.3330.302d.4574.
                    302f.30
192.168.3.2         0063.6973.636f.2d61.    Nov 05 2022 04:19 AM    Automatic
                    6162.622e.6363.3030.
                    2e30.3430.302d.4574.
                    302f.30

パケットキャプチャ

DHCP DISCOVER(CL1→R1)

DHCP DISCOVER(CL1→R1) Packet Capture Text(Click)

Frame 15: 334 bytes on wire (2672 bits), 334 bytes captured (2672 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 0.0.0.0, Dst: 255.255.255.255
User Datagram Protocol, Src Port: 68, Dst Port: 67
Dynamic Host Configuration Protocol (Discover)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 0.0.0.0
    Next server IP address: 0.0.0.0
    Relay agent IP address: 0.0.0.0
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Discover)
    Option: (57) Maximum DHCP Message Size
    Option: (61) Client identifier
    Option: (12) Host Name
    Option: (55) Parameter Request List
    Option: (255) End

DHCP DISCOVER(R1→DHCP-Server)

DHCP DISCOVER(R1→DHCP-Server) Packet Capture Text(Click)

Frame 17: 334 bytes on wire (2672 bits), 334 bytes captured (2672 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:01:30 (aa:bb:cc:00:01:30), Dst: aa:bb:cc:00:05:00 (aa:bb:cc:00:05:00)
Internet Protocol Version 4, Src: 192.168.1.1, Dst: 192.168.4.100
User Datagram Protocol, Src Port: 67, Dst Port: 67
Dynamic Host Configuration Protocol (Discover)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 1
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 0.0.0.0
    Next server IP address: 0.0.0.0
    Relay agent IP address: 192.168.1.1
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Discover)
    Option: (57) Maximum DHCP Message Size
    Option: (61) Client identifier
    Option: (12) Host Name
    Option: (55) Parameter Request List
    Option: (255) End

DHCP OFFER(DHCP-Server→R1)

DHCP OFFER(DHCP-Server→R1) Packet Capture Text(Click)

Frame 20: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:05:00 (aa:bb:cc:00:05:00), Dst: aa:bb:cc:00:01:30 (aa:bb:cc:00:01:30)
Internet Protocol Version 4, Src: 192.168.4.100, Dst: 192.168.1.1
User Datagram Protocol, Src Port: 67, Dst Port: 67
Dynamic Host Configuration Protocol (Offer)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 192.168.1.3
    Next server IP address: 0.0.0.0
    Relay agent IP address: 192.168.1.1
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Offer)
    Option: (54) DHCP Server Identifier (192.168.4.100)
    Option: (51) IP Address Lease Time
    Option: (58) Renewal Time Value
    Option: (59) Rebinding Time Value
    Option: (1) Subnet Mask (255.255.255.0)
    Option: (3) Router
    Option: (15) Domain Name
    Option: (6) Domain Name Server
    Option: (255) End
    Padding: 00

DHCP OFFER(R1→CL1)

DHCP OFFER(R1→CL1) Packet Capture Text(Click)

Frame 17: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:01:00 (aa:bb:cc:00:01:00), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 192.168.1.1, Dst: 255.255.255.255
User Datagram Protocol, Src Port: 67, Dst Port: 68
Dynamic Host Configuration Protocol (Offer)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 192.168.1.3
    Next server IP address: 0.0.0.0
    Relay agent IP address: 192.168.1.1
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Offer)
    Option: (54) DHCP Server Identifier (192.168.4.100)
    Option: (51) IP Address Lease Time
    Option: (58) Renewal Time Value
    Option: (59) Rebinding Time Value
    Option: (1) Subnet Mask (255.255.255.0)
    Option: (3) Router
    Option: (15) Domain Name
    Option: (6) Domain Name Server
    Option: (255) End
    Padding: 00

DHCP REQUEST(CL1→R1)

DHCP REQUEST(CL1→R1) Packet Capture Text(Click)

Frame 18: 346 bytes on wire (2768 bits), 346 bytes captured (2768 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 0.0.0.0, Dst: 255.255.255.255
User Datagram Protocol, Src Port: 68, Dst Port: 67
Dynamic Host Configuration Protocol (Request)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 0.0.0.0
    Next server IP address: 0.0.0.0
    Relay agent IP address: 0.0.0.0
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Request)
    Option: (57) Maximum DHCP Message Size
    Option: (61) Client identifier
    Option: (54) DHCP Server Identifier (192.168.4.100)
    Option: (50) Requested IP Address (192.168.1.3)
    Option: (12) Host Name
    Option: (55) Parameter Request List
    Option: (255) End

DHCP REQUEST(R1→DHCP-Server)

DHCP REQUEST(R1→DHCP-Server) Packet Capture Text(Click)

Frame 21: 346 bytes on wire (2768 bits), 346 bytes captured (2768 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:01:30 (aa:bb:cc:00:01:30), Dst: aa:bb:cc:00:05:00 (aa:bb:cc:00:05:00)
Internet Protocol Version 4, Src: 192.168.1.1, Dst: 192.168.4.100
User Datagram Protocol, Src Port: 67, Dst Port: 67
Dynamic Host Configuration Protocol (Request)
    Message type: Boot Request (1)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 1
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 0.0.0.0
    Next server IP address: 0.0.0.0
    Relay agent IP address: 192.168.1.1
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (Request)
    Option: (57) Maximum DHCP Message Size
    Option: (61) Client identifier
    Option: (54) DHCP Server Identifier (192.168.4.100)
    Option: (50) Requested IP Address (192.168.1.3)
    Option: (12) Host Name
    Option: (55) Parameter Request List
    Option: (255) End

DHCP ACK(DHCP-Server→R1)

DHCP ACK(DHCP-Server→R1) Packet Capture Text(Click)

Frame 22: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:05:00 (aa:bb:cc:00:05:00), Dst: aa:bb:cc:00:01:30 (aa:bb:cc:00:01:30)
Internet Protocol Version 4, Src: 192.168.4.100, Dst: 192.168.1.1
User Datagram Protocol, Src Port: 67, Dst Port: 67
Dynamic Host Configuration Protocol (ACK)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 192.168.1.3
    Next server IP address: 0.0.0.0
    Relay agent IP address: 192.168.1.1
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (ACK)
    Option: (54) DHCP Server Identifier (192.168.4.100)
    Option: (51) IP Address Lease Time
    Option: (58) Renewal Time Value
    Option: (59) Rebinding Time Value
    Option: (1) Subnet Mask (255.255.255.0)
    Option: (3) Router
    Option: (15) Domain Name
    Option: (6) Domain Name Server
    Option: (255) End
    Padding: 00

DHCP ACK(R1→CL1)

DHCP ACK(R1→CL1) Packet Capture Text(Click)

Frame 19: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits) on interface -, id 0
Ethernet II, Src: aa:bb:cc:00:01:00 (aa:bb:cc:00:01:00), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 192.168.1.1, Dst: 255.255.255.255
User Datagram Protocol, Src Port: 67, Dst Port: 68
Dynamic Host Configuration Protocol (ACK)
    Message type: Boot Reply (2)
    Hardware type: Ethernet (0x01)
    Hardware address length: 6
    Hops: 0
    Transaction ID: 0x00000b32
    Seconds elapsed: 0
    Bootp flags: 0x8000, Broadcast flag (Broadcast)
    Client IP address: 0.0.0.0
    Your (client) IP address: 192.168.1.3
    Next server IP address: 0.0.0.0
    Relay agent IP address: 192.168.1.1
    Client MAC address: aa:bb:cc:00:02:00 (aa:bb:cc:00:02:00)
    Client hardware address padding: 00000000000000000000
    Server host name not given
    Boot file name not given
    Magic cookie: DHCP
    Option: (53) DHCP Message Type (ACK)
    Option: (54) DHCP Server Identifier (192.168.4.100)
    Option: (51) IP Address Lease Time
    Option: (58) Renewal Time Value
    Option: (59) Rebinding Time Value
    Option: (1) Subnet Mask (255.255.255.0)
    Option: (3) Router
    Option: (15) Domain Name
    Option: (6) Domain Name Server
    Option: (255) End
    Padding: 00

TCP/IP