Re: Using isc-dhcp-client as alternate dhclient - Alias working (I think)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Using isc-dhcp-client as alternate dhclient - Alias working (I think)

Ted Wynnychenko

I am responding to my original question.
I have been able to get isc-dhcp-client to work assigning an alias on the dhcp
In case this is of value to anyone, here is how I did it.

Obviously, I added isc-dhcp-client from packages.

I then created a new configuration file I called "isc-dhclient.conf"

In it, following the isc dhclient.conf man page, I added an "alias" section,

alias {
        interface "em0";
        option subnet-mask;

Now, it seems, the isc dhclient modifies things on the system by calling
"dhclient-script" and passing it information as environment variables.  I
realized that the reason alias information wasn't being assigned was because the
"out-of-the-box" script included with the package completely ignores any alias
information sent to it.

So, I added two functions, and called them at (I think) the appropriate places,
to a new file dhclient-script-alias.
# diff /usr/local/sbin/dhclient-script /usr/local/sbin/dhclient-script-alias

> add_new_alias() {
>       if [ -n "$alias_ip_address" ]; then
>               ifconfig $interface inet alias $alias_ip_address netmask \
>                       $alias_subnet_mask
>       fi
> }
> delete_old_alias() {
>       if [ -n "$alias_ip_address" ]; then
>               ifconfig $interface inet $alias_ip_address delete > /dev/null
>       fi
> }
>               if [ "$old_ip_address" != "$alias_ip_address" ]; then
>                       delete_old_alias
>               fi
>       if [ "$new_ip_address" != "$alias_ip_address" ]; then
>               add_new_alias
>       fi
>       delete_old_alias
>       delete_old_alias

Went back add added a "script" line to the isc-dhclient.conf file, as:

        script "/usr/local/sbin/dhclient-script-alias";

Then modified /etc/hostname.em0 to run the isc dhclient.  But, before starting
the client, the interface needs to be brought up.  This resulted in:

# cat hostname.em0
! ifconfig em0 up
! /usr/local/sbin/dhclient -4 -cf /etc/isc-dhclient.conf -pf
/var/db/ em0

(I "know" - well, actually, "think" - that I could just use "up" for the first
line, but I did it this way.)

I also specified the /var/db location for the pid file, as the default location
(/var/run) for the pid file did not seem to work when starting the client during
boot (I don't know exactly why, but there was no "" file present in
/var/run after boot, although it is created when starting the isc dhclient
manually on a running system).

Finally, I deleted a /etc/mygate file that was hanging around on the system.  (I
couldn't figure out why the default route was not being set correctly, but
eventually realized that removing the "dhcp" line from the hostname file told
netstart to stop ignoring the mygate file that was present, and so netstart
would reset the default route after the isc dhclient had set it correctly.)

So, I don't know if this will be of help to anyone.  I don't even know if the is
a sane way to do this.

But, I did come across a question or two about alias addresses with dhcp on
openbsd in the relatively recent past, so...


[demime 1.01d removed an attachment of type application/x-pkcs7-signature which had a name of smime.p7s]