Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
dhclient vs udhcpc
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
joanandk
Apprentice
Apprentice


Joined: 12 Feb 2017
Posts: 169

PostPosted: Tue Nov 28, 2017 11:15 am    Post subject: dhclient vs udhcpc Reply with quote

Hi,

As many of you know, there are multiple possibilities to get dhcp client script on the machine:
a) using dhcpcd
b) using the built in udhcpc

I have found no documentation on the udhcpc. So far I have seen that udhcpc cannot be invoked as a command, but by restarting the network interface via the init.d script.

Has someone a deeper insight? What other advantages are there with the "external" dhcp-client script?

Does udhcpc have support for dhcp-hooks (I have not seen any support)?
What is your recommendation? Installing dhcpcd on new systems or make use of udhcpc?

Thanks.
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Nov 28, 2017 1:07 pm    Post subject: Reply with quote

udhcpc is busybox implementation of dhcp
while dhcpcd is roy marples implementation of dhcp

these aren't facts ; it's only base on my thinking: "busybox tools are simple and functional and aim to stay tiny, dhcpcd is made by roy marples: it then could only be top tool".
So for me, if you want "i need a client to ask dhcp server an ip", udhcpc should do the work, but if you want extra features, dhcpcd is there.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Tue Nov 28, 2017 2:57 pm    Post subject: Reply with quote

udhcpc is a very small DHCP client that provides a very limited (but also the most useful) set of DHCP options to a shell script which then configures the address, routing and DNS.
On Gentoo it's available via the net.* DHCP modules. It does have a hook script of sorts, but it's just one script that Gentoo supplies with no way of extending it.
udhcpc is only available on Linux.

dhcpcd is quite larger (well, 220k on NetBSD i386) but decodes all RFC DHCP options and allows custom ones to be made as well.
It configures the address and routing internally and then sends everything else to a shell script for futher configuration such as DNS. You can roll your own hook scripts easily.
man page here.
On Gentoo it's available via the net.* DHCP modules OR available as it's own init script (this is the preferred way).
dhcpcd also works on BSD, QNX and Solaris platforms.
It's also the tool of choice on Android (although an old version)

dhcpcd also does a lot lot more than udhcpc - static IPv4, IPv4LL, ARP DaD, IPv6 (static and RS), DHCPv6, DHCP4/6 authenticaton and a whole load more stuff.
This could all be compiled out to reduce the overall size to under 100k.
It also works very well with >1 interface (say wired and wireless) on the same subnet.
There's a whole truck of other things dhcpcd does that no other does. Generally if there is something it cannot do, just ask and usually it gets implemented.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Nov 28, 2017 5:00 pm    Post subject: Reply with quote

See, my resume wasn't bad: "it then could only be top tool" :)
Back to top
View user's profile Send private message
joanandk
Apprentice
Apprentice


Joined: 12 Feb 2017
Posts: 169

PostPosted: Wed Nov 29, 2017 12:08 pm    Post subject: Reply with quote

Thanks you both.

The link is superb from UberLord. I have used /lib/dhcp/dhcp-hooks/99_custom upto now, but /etc/dhcpcd.enter-hook is more backup-friendly and will be migrating soon.

BR
Back to top
View user's profile Send private message
joanandk
Apprentice
Apprentice


Joined: 12 Feb 2017
Posts: 169

PostPosted: Mon Dec 11, 2017 4:46 pm    Post subject: Reply with quote

Hi Guys,

I was using /etc/dhcpcd.exit-hook to determine if we are in the intranet. If not openvpn is started. This is not working (openvpn is started but fails to connect and times out). Do you know how I could make it work?

Code:
# VPN-Interface
VPNIF="tap0"

# LAN-Network
VPNET="172.16.1"

# VPN script
VPPGM="/etc/init.d/net.tap0"

# Functions
start_vpn(){
        NETWORK=$(echo "$new_ip_address" | cut -d. --fields=1,2,3)
        if [ "$NETWORK" != "$VPNET" ]; then
                $VPPGM start &
        else
                $VPPGM stop &
        fi
}

if [ "$interface" == "$VPNIF" ]; then
        logger "DHCPcD: The interface belongs to VPN. Starting LAN services ..."
        exit 1
fi

if [ ! -f "$VPPGM" ]; then
        logger "DHCPcD: Script for VPN not found. Exiting ..."
        exit 1
fi

case "${reason}" in
        BOUND|RENEW|REBIND)
                start_vpn
                ;;
        EXPIRE|FAIL|STOP|TIMEOUT)
                $VPPGM stop &
        ;;
esac


I have tried with dhcpcd.enter-hook, that failed too, and I thought it was due to resolv.conf not getting ready for openvpn. The net.tap0 has dependency to openvpn, so executing net.tap0 calls openvpn.

Manually I can start net.tap0 and it works.

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum