This is basically for Bruce - he wants to get dhcp-4.2.3 working
for LFS-7.0, so here are my experiences with dhcp-4.2.2 on LFS-6.8.
For those with a long memory, I *had to* move to recent dhcp-4.2
because the older versions don't build on linux 3.X. I have no need
for, nor current interest in, the ipv6 features.
Attached are two patches - one for both client and server (missing
ipv6 not fatal). On the desktop where I was testing, ipv6 was
already compiled into the kernel, but I note that it isn't compiled
in on my server, so I guess I can say this patch works. It came
from fedora, but for some reason I had to apply part of it by hand
and rediff.
The second patch is for the client, and heir to the old dhcp-3
iproute2 patches, although it originated on the dhcp lists. I
altered it slightly (mainly to remove a lot of >/dev/null so that I
can see any errors, but perhaps also to edit one or two
net-tools-isms that were still there. When I first mentioned this,
I was unsure about it, but I now think it's working as well as the
old BLFS versions - an RTNETLINK error on first shutdown, but
nothing else that I noticed (or, perhaps my shutdowns are too
quick for me to read the errors!)
4.2.2 includes some bind libraries, but since isc is home to both
projects that seems a low risk. Gentoo has a patch to use system
bind, and I think a fixup to force make -j1 for some of it. I only
ever build without specifying -j (I like my logs in order if the
build breaks!).
Dhcp4 is very much a bsd package, some of the defaults are a bit
odd.
Note that net-tools is only a runtime dependency for the unpatched
*client*.
There might be a bug in the client bootscript - during boot, my
machines seem to ask for a lease twice, the second time about 6
seconds after the first (perhaps related to replaying udev events?)
and I also see other requests only a few minutes after a previous
acknowledgement. This hasn't changed recently, and it all still
works ok.
Client
------
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
--sbindir=/sbin \
--with-cli-lease-file=/var/state/dhclient.leases \
--with-cli6-lease-file=/var/state/dhclient6.leases
I follow this with a sed from gentoo to reduce what gets built:
sed -i -e 's/ dhcpctl relay server//' Makefile
make ; make check if you wish ; make install
this installs a useless /etc/dhclient.conf (unless you are the
maintainer who runs some flavour of bsd), so that needs to be
overwritten, the BOOK's values in dhcpclient.{html,xml} seem ok.
It also fails to install a dhclient script, or to create the
directory where it will put its leases (or maybe that's my error
elsewhere), so:
install -v -m755 client/scripts/linux /sbin/dhclient-script
mkdir -pv /var/state
the static libdst.a and libomapi.a get installed and can be deleted,
although no other package is likely to look for them.
Server
------
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
--sbindir=/sbin \
--with-srv-lease-file=/var/state/dhcp/dhcpd.leases \
--with-srv6-lease-file=/var/state/dhcp/dhcpd6.leases
make ; make check if you wish ; make install
this time it installs useless /etc/{dhcpd,dhclient}.conf and fails
to create the file for the server leases:
mkdir -pv /var/state/dhcp
touch /var/state/dhcp/dhcpd.leases
I suppose dhcpd6.leases should also be touched if you intend to use
ipv6.
It also installs libdhcpctl.a as well as the other two static libs,
again no obvious point to that.
Dhcp is now in /sbin (perhaps that's an error with *my* configure
options), so I fix the bootscript
sed -i 's%/usr\(/sbin/dhcp\)%\1%g' /etc/rc.d/init.d/dhcp
and of course I also have to change it to the correct interface.
In dhcpd.conf, the existing instructions need to be changes,
ddns-update-style ad_hoc is no longer supported. The default is
'none' which works fine for me, so jsut remove that line.
ĸen
--
das eine Mal als Tragödie, das andere Mal als Farce
>From fedora, fixed up to apply to 4.2.2 (to me, it looks identical to the 4.2.0
version, but patch failed in one hunk when I tried to apply that).
--- dhcp-4.2.2/common/discover.c.orig 2011-07-19 23:22:48.000000000 +0100
+++ dhcp-4.2.2/common/discover.c 2011-09-06 01:28:15.000000000 +0100
@@ -455,7 +455,7 @@
}
#ifdef DHCPv6
- if (local_family == AF_INET6) {
+ if ((local_family == AF_INET6) && !access("/proc/net/if_inet6", R_OK)) {
ifaces->fp6 = fopen("/proc/net/if_inet6", "r");
if (ifaces->fp6 == NULL) {
log_error("Error opening '/proc/net/if_inet6' to "
@@ -466,6 +466,8 @@
ifaces->fp = NULL;
return 0;
}
+ } else {
+ ifaces->fp6 = NULL;
}
#endif
@@ -733,7 +735,7 @@
return 1;
}
#ifdef DHCPv6
- if (!(*err)) {
+ if (!(*err) && ifaces->fp6) {
if (local_family == AF_INET6)
return next_iface6(info, err, ifaces);
}
@@ -752,7 +754,8 @@
ifaces->sock = -1;
#ifdef DHCPv6
if (local_family == AF_INET6) {
- fclose(ifaces->fp6);
+ if (ifaces->fp6)
+ fclose(ifaces->fp6);
ifaces->fp6 = NULL;
}
#endif
originally from Peter Marschall,
https://lists.isc.org/pipermail/dhcp-users/2011-January/012539.html
upstream status unknown.
extended to handle other 'route' invocations in 4.2.2,
and output to /dev/null removed, by Ken Moffat as a homage to the dhcp3 LFS
patch
by Jim Gifford, Bruce Dubbs, and DJ Lucas.
Buggy! When I first reboot, there is an RTNETLINK error on the console, but
it is
working.
--- dhcp-4.2.2/client/scripts/linux.orig 2011-05-18 21:01:54.000000000
+0100
+++ dhcp-4.2.2/client/scripts/linux 2011-09-06 01:04:13.000000000 +0100
@@ -3,6 +3,8 @@
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
# No guarantees about this. I'm a novice at the details of Linux
# networking.
+# Conversion to use ip for ipv4 (instead of ifconfig, route) by Peter Marschall
+# Extended for 4.2.2, and ip output to /dev/null removed, by Ken Moffat
# Notes:
@@ -98,17 +100,11 @@
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
-if [ x$new_subnet_mask != x ]; then
- new_subnet_arg="netmask $new_subnet_mask"
+if [ -n "$new_subnet_mask" ]; then
+ new_mask="/$new_subnet_mask"
fi
-if [ x$old_subnet_mask != x ]; then
- old_subnet_arg="netmask $old_subnet_mask"
-fi
-if [ x$alias_subnet_mask != x ]; then
- alias_subnet_arg="netmask $alias_subnet_mask"
-fi
-if [ x$new_interface_mtu != x ]; then
- mtu_arg="mtu $new_interface_mtu"
+if [ -n "$alias_subnet_mask" ]; then
+ alias_mask="/$alias_subnet_mask"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
@@ -122,9 +118,9 @@
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
# Bring down alias interface. Its routes will disappear too.
- ifconfig $interface:0- inet 0
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
fi
- ifconfig $interface 0 up
+ ${ip} link set dev ${interface} up
# We need to give the kernel some time to get the interface up.
sleep 1
@@ -151,25 +147,32 @@
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
# Possible new alias. Remove old alias.
- ifconfig $interface:0- inet 0
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ];
then
# IP address changed. Bringing down the interface will delete all routes,
# and clear the ARP cache.
- ifconfig $interface inet 0 down
+ ${ip} -4 addr flush dev ${interface} label ${interface}
+ fi
+
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
- ifconfig $interface inet $new_ip_address $new_subnet_arg \
- $new_broadcast_arg $mtu_arg
+ ${ip} -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \
+ dev ${interface} label ${interface}
+ if [ -n "$new_interface_mtu" ]; then
+ # set MTU
+ ${ip} link set dev ${interface} mtu ${new_interface_mtu}
+ fi
# Add a network route to the computed network address.
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
- route add -host $router dev $interface
+ ${ip} -4 route add ${router} dev $interface
fi
- route add default gw $router $metric_arg dev $interface
+ ${ip} -4 route add default via ${router} dev ${interface} \
+ ${metric_arg}
done
else
# we haven't changed the address, have we changed other options
@@ -177,21 +180,24 @@
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
for router in $old_routers; do
- route del default gw $router
+ ${ip} -4 route del via $router
done
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
- route add -host $router dev $interface
+ ${ip} -4 route add $router dev $interface
fi
route add default gw $router $metric_arg dev $interface
+ ${ip} -4 route add default via $router dev $interface \
+ $metric_arg
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
- ifconfig $interface:0- inet 0
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address $interface:0
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
+ ${ip} -4 addr add ${alias_ip_address}${alias_mask} \
+ dev ${interface} label ${interface}:0
+ ${ip} -4 route add ${alias_ip_address} dev ${interface}
fi
make_resolv_conf
exit_with_hooks 0
@@ -201,42 +207,49 @@
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
# Turn off alias interface.
- ifconfig $interface:0- inet 0
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
fi
if [ x$old_ip_address != x ]; then
# Shut down interface, which will delete routes and clear arp cache.
- ifconfig $interface inet 0 down
+ ${ip} -4 addr flush dev ${interface} label ${interface}
fi
if [ x$alias_ip_address != x ]; then
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address $interface:0
+ ${ip} -4 addr add ${alias_ip_address}${alias_network_arg} \
+ dev ${interface} label ${interface}:0
+ ${ip} -4 route add ${alias_ip_address} dev ${interface}
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
- ifconfig $interface:0- inet 0
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
+ fi
+ ${ip} -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \
+ dev ${interface} label ${interface}
+ if [ -n "$new_interface_mtu" ]; then
+ # set MTU
+ ip link set dev ${interface} mtu ${new_interface_mtu}
fi
- ifconfig $interface inet $new_ip_address $new_subnet_arg \
- $new_broadcast_arg $mtu_arg
set $new_routers
if ping -q -c 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address dev $interface:0
+ ${ip} -4 addr add ${alias_ip_address}${alias_mask} \
+ dev ${interface} label ${interface}:0
+ ${ip} -4 route add ${alias_ip_address} dev ${interface}
fi
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
- route add -host $router dev $interface
+ ${ip} -4 route add ${router} dev $interface
fi
- route add default gw $router $metric_arg dev $interface
+ ${ip} -4 route add default via ${router} dev ${interface} \
+ ${metric_arg}
done
make_resolv_conf
exit_with_hooks 0
fi
- ifconfig $interface inet 0 down
+ ${ip} -4 addr flush dev ${interface}
exit_with_hooks 1
fi
--
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page