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

2016-10-13 Thread Ted Wynnychenko
Hello

I am responding to my original question.
I have been able to get isc-dhcp-client to work assigning an alias on the dhcp
interface.
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,
e.g.:

alias {
interface "em0";
fixed-address 10.0.0.0;
option subnet-mask 255.255.255.0;
}

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
23a24,36
> 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
2>&1
>   fi
> }
>
186a200,203
>   if [ "$old_ip_address" != "$alias_ip_address" ]; then
>   delete_old_alias
>   fi
>
198a216,218
>   if [ "$new_ip_address" != "$alias_ip_address" ]; then
>   add_new_alias
>   fi
216a237
>   delete_old_alias
237a259
>   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/dhclient.pid 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 "dhclient.pid" 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...

Ted

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



Re: Using isc-dhcp-client as alternate dhclient

2016-09-23 Thread Stuart Henderson
On 2016-09-20, Theodore Wynnychenko  wrote:
> First, I can't get the isc-dhcp-client to assign an alias to the interface,
> despite the documentation that states it should.

It seems to work if you preset the alias address on the interface
before running dhclient.

> Second, I (apparently) don't understand how to replace the base dhclient with
> the isc dhclient at boot.
>
> I tried modifying /etc/hostname.em0 from:
> ---
> dhcp NONE NONE NONE description "Uplink"
> ---
>
> To:
> ---
> ! /usr/local/sbin/dhclient -cf /etc/isc-dhclient.conf em0
> ---
>
> But this did not work.

Please define "did not work". What output did you get ("dmesg -s" might
help), what shows up in logs, etc?

> I now see in the hostname.if manpage that the command
> needs to be available in the single-user environment (/bin or /sbin)

AFAIK this is mostly for systems with /usr/local on NFS. I certainly
have some ports things successfully started from ! lines in hostname.if
files.



Re: Using isc-dhcp-client as alternate dhclient

2016-09-20 Thread Edgar Pettijohn
On 16-09-20 15:36:52, Theodore Wynnychenko wrote:
> Hello
> I would like to get the isc-dhcp-client working as a replacement for the base
> dhclient.
> 
> The primary reason for this is so that I can assign an alias to the interface.
> 
> But, I can't seem to figure out how to get this done.  I have two issues.
> 
> First, I can't get the isc-dhcp-client to assign an alias to the interface,
> despite the documentation that states it should.
> 
> I have created an /etc/isc-dhclient.conf file:
> ---
> timeout 60;
> retry 60;
> reboot 10;
> select-timeout 5;
> initial-interval 2;
> script "/usr/local/sbin/dhclient-script";
> 
> supersede domain-name "domain.com";
> supersede domain-name-servers d.n.s.1,d.n.s.2;
> 
> request subnet-mask, broadcast-address, time-offset, routers;
> 
> alias {
>   interface "em0";
>   fixed-address fi.xed.ip.addr;
>   option subnet-mask 255.255.255.0;
> }
> ---
> 
> But, after killing the running dhclient process (from base), removing the 
> leases
> at /var/db/dhclient.leases* and starting isc-dhcp-client with:
> 
> # /usr/local/sbin/dhclient -cf /etc/isc-dhclient.conf em0
> 
> the isc client is able to get a an offer from the dhcp server, but it does 
> _not_
> assign the alias address to the interface.  The only address is the 
> dynamically
> assigned one.
> 
> I can find no guidance on what I am doing wrong, and why the isc-dhcp-client 
> is
> not assigning the alias.
> 
> Second, I (apparently) don't understand how to replace the base dhclient with
> the isc dhclient at boot.
> 
> I tried modifying /etc/hostname.em0 from:
> ---
> dhcp NONE NONE NONE description "Uplink"
> ---
> 
> To:
> ---
> ! /usr/local/sbin/dhclient -cf /etc/isc-dhclient.conf em0
> ---
> 
> But this did not work.  I now see in the hostname.if manpage that the command
> needs to be available in the single-user environment (/bin or /sbin), but it
> seems to me that if I was doing this "right," I shouldn't need to move the isc
> client from the location that the package installed it in.  So, before I start
> moving things around, I wanted to check if this is the way to do it, or if I
> have missed something more appropriate.
> 
> Thanks for any advice.
> 
> Ted

ALIAS DECLARATIONS
alias {  declarations ... }

   Some DHCP clients running TCP/IP roaming protocols may require that in
   addition to the lease they may acquire via DHCP, their interface also
   be configured with a predefined IP alias so that they can have a
   permanent IP address even while roaming.  The Internet Systems
   Consortium DHCP client doesn't support roaming with fixed addresses
   directly, but in order to facilitate such experimentation, the dhcp
   client can be set up to configure an IP alias using the alias
   declaration.

   The alias declaration resembles a lease declaration, except that
   options other than the subnet-mask option are ignored by the standard
   client configuration script, and expiry times are ignored.  A typical
   alias declaration includes an interface declaration, a fixed-address
   declaration for the IP alias address, and a subnet-mask option
   declaration.  A medium statement should never be included in an alias
   declaration.

I think they are saying their dhcp-client cant handle fixed ip's so this is
some sort of workaround. These aren't the droids you're looking for. 

-- 
Edgar Pettijohn



Using isc-dhcp-client as alternate dhclient

2016-09-20 Thread Theodore Wynnychenko
Hello
I would like to get the isc-dhcp-client working as a replacement for the base
dhclient.

The primary reason for this is so that I can assign an alias to the interface.

But, I can't seem to figure out how to get this done.  I have two issues.

First, I can't get the isc-dhcp-client to assign an alias to the interface,
despite the documentation that states it should.

I have created an /etc/isc-dhclient.conf file:
---
timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
script "/usr/local/sbin/dhclient-script";

supersede domain-name "domain.com";
supersede domain-name-servers d.n.s.1,d.n.s.2;

request subnet-mask, broadcast-address, time-offset, routers;

alias {
  interface "em0";
  fixed-address fi.xed.ip.addr;
  option subnet-mask 255.255.255.0;
}
---

But, after killing the running dhclient process (from base), removing the leases
at /var/db/dhclient.leases* and starting isc-dhcp-client with:

# /usr/local/sbin/dhclient -cf /etc/isc-dhclient.conf em0

the isc client is able to get a an offer from the dhcp server, but it does _not_
assign the alias address to the interface.  The only address is the dynamically
assigned one.

I can find no guidance on what I am doing wrong, and why the isc-dhcp-client is
not assigning the alias.

Second, I (apparently) don't understand how to replace the base dhclient with
the isc dhclient at boot.

I tried modifying /etc/hostname.em0 from:
---
dhcp NONE NONE NONE description "Uplink"
---

To:
---
! /usr/local/sbin/dhclient -cf /etc/isc-dhclient.conf em0
---

But this did not work.  I now see in the hostname.if manpage that the command
needs to be available in the single-user environment (/bin or /sbin), but it
seems to me that if I was doing this "right," I shouldn't need to move the isc
client from the location that the package installed it in.  So, before I start
moving things around, I wanted to check if this is the way to do it, or if I
have missed something more appropriate.

Thanks for any advice.

Ted