Commands / Services and tunnels

Services and tunnels

dhcrelay

Also dhcp relay, relay agent, ip helper-address, helper address, giaddr, option 82

Relays DHCP: passes clients' broadcasts on to a DHCP server on another network, as `ip helper-address` does on IOS.

ISC's relay agent listens for clients on the downstream cards (-id), sends each request by unicast to the server, with the card's own address as the giaddr and the hop count raised, and passes the server's reply (sent to that giaddr) back to the client. -a adds option 82, relay agent information, whose circuit ID names the card; the relay takes it off the replies. On Cisco IOS the same is one line on the client-facing interface: ip helper-address 10.0.3.10.

dhcrelay command usage

dhcrelay -4 [-a] -id DOWNSTREAM_CARD ... -iu UPSTREAM_CARD ... SERVER

Options

-4
relay DHCP for IPv4
-id eth0
a card with clients on it (downstream); repeat for each
-iu eth2
a card towards the server (upstream)
-a
add option 82, relay agent information (circuit ID: the card's name)
-pf FILE
write the daemon's process ID to FILE
-d
stay in the foreground and log to the terminal

dhcrelay examples

dhcrelay -4 -id eth0 -id eth1 -iu eth2 10.0.3.10
Relays requests from eth0 and eth1 to the server at 10.0.3.10, reached by eth2.
tcpdump -nn -i any -v udp port 67
Shows each request twice: broadcast by the client, then relayed with its Gateway-IP.

Pitfalls

  • The server replies to the giaddr: without a route back to the relay's client networks, requests arrive and offers are never delivered.
  • The server must have a pool (scope) for the giaddr's subnet, or it ignores the request.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab