DHCP リレーの概要

DHCP リレー エージェントは、共有の物理サブネットに存在しないクライアントとサーバとの間で DHCP パケットを転送するホストです。リレー エージェント転送は、IP ルータの通常の転送とは異なります。通常の転送では、IP データグラムがネットワーク間で透過的にスイッチングされます。

DHCP クライアントは、自身の所属先のネットワークに関する情報を保持していないときには、ユーザ データグラム プロトコル(UDP)ブロードキャストを使用して、DHCPDISCOVER メッセージを送信します。

サーバが含まれていないネットワーク セグメント上にクライアントがある場合、DHCP パケットが別のネットワーク セグメント上のサーバに届くようにするには、そのネットワーク セグメントにリレー エージェントが必要です。ほとんどのルータはブロードキャスト トラフィックを転送するように設定されていないため、UDP ブロードキャスト パケットは転送されません。DHCP リレー プロファイルを設定することにより DHCP パケットをリモート サーバに転送するように DHCP リレー エージェントを設定し、そこに 1 つ以上のヘルパー アドレスを設定できます。プロファイルをインターフェイスまたは VRF に割り当てることができます。

次の図に、このプロセスを示します。DHCP クライアントが、IP アドレスの要求と追加設定パラメータをローカル LAN 上でブロードキャストしています。DHCP リレー エージェントとして機能するルータ B は、ブロードキャストを取得し、宛先アドレスを DHCP サーバのアドレスに変更し、別のインターフェイスにメッセージを送信します。リレー エージェントは、DHCP クライアントのパケットを受け取ったインターフェイスの IP アドレスを DHCP パケットのゲートウェイ アドレス(giaddr)フィールドに挿入します。これにより、DHCP サーバは、どのサブネットがオファーを受信するかを判断し、適切な IP アドレス範囲を特定できます。リレー エージェントは、メッセージを(リレー プロファイルのヘルパー アドレスによって指定される)サーバ アドレス、この場合は 172.16.1.2 にユニキャストします。

図 1. ヘルパー アドレスを使用した UDP ブロードキャストの DHCP サーバへの転送

DHCP リレー エージェントの設定およびイネーブル化

設定例

RP/0/RP0/CPU0:router# configure
/* Enters the global configuration mode */

RP/0/RP0/CPU0:router(config)# dhcp ipv4
/* Configures DHCP for IPv4 and enters the DHCPv4 configuration submode. */

RP/0/RP0/CPU0:router(config-dhcpv4)# profile r1 relay
/* Enables DHCP relay profile */

RP/0/RP0/CPU0:router(config-dhcpv4-relay-profile)# helper-address vrf A 10.10.10.1 giaddr 40.1.1.2
RP/0/RP0/CPU0:router(config-dhcpv4-relay-profile)# broadcast-flag policy check
/* Configures VRF addresses for forwarding UDP broadcasts, including BOOTP and DHCP. */

RP/0/RP0/CPU0:router(config-dhcpv4-relay-profile)# relay information option vpn
RP/0/RP0/CPU0:router(config-dhcpv4-relay-profile)# relay information option vpn-mode rfc
/* Inserts the DHCP relay agent information option (option-82 field) in forwarded BOOTREQUEST messages to a DHCP server. */


RP/0/RP0/CPU0:router(config-dhcpv4-relay-profile)# relay information option allow-untrusted
/* (Optional) Configures the DHCP IPv4 Relay not to discard BOOTREQUEST packets 
that have an existing relay information option and the giaddr set to zero. */

RP/0/RP0/CPU0:router(config-dhcpv4-relay-profile)# exit
RP/0/RP0/CPU0:router(config-dhcpv4)# interface BVI 1 relay profile r1
RP/0/RP0/CPU0:router(config-dhcpv4)# commit
/* Configures DHCP relay on a BVI interface and commits the configuration */

実行コンフィギュレーション

RP/0/RP0/CPU0:router#show running-config
Tue May 23 10:56:14.463 IST
Building configuration...
!! IOS XR Configuration 0.0.0
!! Last configuration change at Tue May 23 10:56:08 2017 by annseque
!
dhcp ipv4
 vrf vrf1 relay profile client
 profile r1 relay
  helper-address vrf A 10.10.10.1 giaddr 40.1.1.2
  broadcast-flag policy check
  relay information option vpn
  relay information option vpn-mode rfc
  relay information option allow-untrusted
 !