/q-dhcp-client

DHCP client for my LFS build

Primary LanguageC

q-dhcp-client

Compilation:
DEBUG_DIR_PATH - path to dir where .bin files will be created in -d mode
ARP_ROUTER - added solely for test purpose, it will force client to do ARP request not to requested ip, but to ip of router
This will result in receiving IP_OCCUPIER

Installing:
1)Edit Makefile to satisfy your requirements and tools
2)Execute `make`
3)If you want - you can do `make check`, but read warning
Install in any place by moving/copying ./q-dhcp-client

Usage options:
-d - show debug info
-i <interface name> - specify interface to work with
--dry - do not edit interface ip, mask and routes
--arp-check - perform arp check after receiving DHCP_OFFER
send DHCP_DECLINE if dhcp client receives ARP_REPLY
--release - send DHCP_RELEASE to free current ip
--no-debug-files - do not create .bin debug files when -d option used

Return codes:
0 - OK
-1 - Internal error
-2 - IP already occupied or got DHCP_NAK
Always prints IP:NETMASK:GATEWAY IP:LEASE TIME(s), so you can parse it with `cut`

Examples:
#Get ip addr, perform arp check
#Set ip addr, net mask and default route for device eth0 if ip is free
q-dhcp-client -i eth0 --arp-check

#Get ip and set ip, mask and route
q-dhcp-client -i eth0

#Send DHCP_RELEASE and delete ip addr from device
q-dhcp-client -i eth0 --release

#Get ip(without setting it in device) and print debug info
q-dhcp-client -i eth0 --dry -d


I use it for my LFS build with runit