[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: DHCP with Static Addresses



On Fri, Nov 25, 2005 at 12:02:47PM -0500, Kenneth Jacker wrote:
>   am> server.  Assuming you're using dhcpd you'll want something
>   am> similar to this in your dhcpd.conf:
> 
>   am> host yourhostname {
>   am>   hardware ethernet 00:11:22:AA:BB:CC;
>   am>   fixed-address 192.168.0.123;
>   am> }
> 
> Good idea!
> 
> However, 'dhcpd' is running within my LinkSys router, not on one of my
> Debian boxen ...
> 
> I spent quite a few minutes going through the router's option pages,
> but couldn't see a way to specify this.

I have a Linksys wireless router that, as far as I can tell, can't
be configured as suggested above (without changing the firmware).
Fortunately, you can use /etc/dhclient.conf on the client instead of
dhcpd.conf on the router to accomplish something similar.

I have this in /etc/dhclient.conf:
alias {
  interface "eth0";
  fixed-address 192.168.1.101;
  option subnet-mask 255.255.255.0;
}
--------------------------------

And this in /etc/network/interfaces:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
----------------------------

This setup works with port forwarding for ssh and, as far as I know,
everything else but openvpn. To make it work for openvpn I also changed
/etc/dhclient-script to promote the fixed-address, which manifests
only as an alias, to the primary address.

$diff -u /etc/dhclient-script.dist /etc/dhclient-script
--- /etc/dhclient-script.dist	2005-11-26 09:01:15.000000000 -0500
+++ /etc/dhclient-script	2005-11-26 09:00:43.000000000 -0500
@@ -123,6 +123,12 @@
   exit_with_hooks 0
 fi
 
+if [ x$alias_ip_address != x ] ; then
+  given_ip_address=$new_ip_address;
+  new_ip_address=$alias_ip_address;
+  alias_ip_address=$given_ip_address;
+fi
+
 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
    [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
   if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \

--------------------

If you're not familiar with context diffs, the lines beginning with a
single '+' are what was added by me.  Hope that helps.

Win



Reply to: