[KLUG Members] DHCP / SAMBA

Bryan-TheBS-Smith members@kalamazoolinux.org
Mon, 06 Aug 2001 08:47:53 -0400


Bill wrote:
> How do I feed addresses assigned by DHCP to SAMBA so that SAMBA
> (on my Linux box) can find my wifes Win98 box?

Okay, the first thing to remember is that NetBIOS name resolution is
_different_ DNS name resolution.  And the differentiation can get
"tricky."  NetBIOS is, by default, _very_active_ and _dynamic_ in
its exploration of IP addresses (and can use various methods, I
recommend WINS as the default, with your Samba server as the WINS
server), but only Samba can use NetBIOS (at least without
modification of the underlying UNIX resolver).  DNS is
_very_passive_, meaning your DNS records should reflect the correct
IP address of a system at any time.  Everything else uses DNS.

So what "I think" you are asking is what is the best way to deal
with the fact that my client's IPs might be DHCP assigned, correct? 
The answer lies in tying the 6-byte IEEE MAC (media access
controller) Ethernet address of your DHCP clients to specific IP
addresses.  I.e., you modify your DHCP server so it always gives the
_same_ IP address to the same clients, who always have the same
Ethernet address.  Now I see you're not using Linux as your DHCP
server, so verify your "router" can assign static IPs under its DHCP
server.

Now it seems you are using Samba as a server?  As such, it does NOT
matter what the IP address of your clients are, as long as they are
on the same "subnet" as the server.  You should also probably add a
"hosts allow" line into your smb.conf file to make sure it is
allowing clients on the same subnet to access it.  E.g.
/etc/smb.conf (assuming your LAN was "192.168.128.0/255.255.255.0"
and your server is "192.168.128.64"):

        workgroup = MYWORKGROUP
        netbios name = MYSERVER
        server string = Samba %v
        interfaces = 127.0.0.1/8 192.168.128.64/24
        encrypt passwords = Yes
        name resolve order = wins lmhosts host bcast
        map to guest = Bad User
        os level = 96
        preferred master = Yes
        domain master = Yes
        wins proxy = Yes
        wins support = Yes
        socket address = 127.0.0.1 192.168.128.64
        hosts allow = 127. 192.168.128.

But the Samba server itself _should_always_ have the same IP address
-- it's best.  As such, either statically assign one, or setup your
DHCP server to do so.  In any case, you _should_ probably setup a
DNS server for your internal LAN (for various reasons) -- and a DNS
server _must_ have a static IP anyway, which would probably be your
file server.

> How do I use addresses generated by DHCP to connect my two Linux
> boxes (nfs / ssh?)

Er, SSH is not needed unless you are going to tunnel NFS to a
remotely connected subnet.

As you have probably found out, NFS is the Network Filesystem, the
UNIX native file server.

Same principle as Samba.  Server should be static, clients can be
static or dynamic.  You can allow access based on real DNS names, or
IP address.  E.g. /etc/exports:
   /home	*.myworkgroup.mydomain.com(rw)
192.168.128.0/255.255.255.0(rw)

> I know I can assign static ip's within the range my router will
> allow, but I want to "set it and forget it" so as to make future
> additions to the stable relatively painless.

That's fine for the clients.  But the server _should_ be static. 
It's just best.  And you should probably setup private DNS for your
LAN -- which will need to be on a static IP anyway.

> DHCP seems the way to go on that.

Now you _can_ assign static IPs via DHCP, again, based on Ethernet
MAC address, but I still don't recommend it for the server.  There
is too much "hard coded" in all the services so it will *NOT* be
"set it and forget it" if you ever change your network.

And the private LAN IPs don't change.  They are permanently fixed
as:
   192.168.0.0 - 192.168.254.0 / 255.255.255.0
   172.16.0.0 - 172.31.0.0 / 255.255.0.0
   10.0.0.0 / 255.0.0.0

> I have Rod Smiths book "Linux: Networking for Your Office" but,
> if he covers this material, I am overlooking it.

No book could show the literally millions of examples and possible
issues.  That's the problem.  ;-PPP

> Basically I am set up like this:
> Machine OS              Scope
> a.genesis.com   Mdk 8.0         Workstation (manage b.genesis / add
>                                 content to website / databases; general surfing & email)
> b.genesis.com   Mdk 8.0         Server (NFS, SMB, SSH, HTTPD, PHP,
>                                 Postgresql, Mysql)
> c.genesis.com   Win98           Workstation (add content to website /
>                                 databases; general surfing & email) Using ZoneAlarm and
>                                 Norton Internet Security Family Edition (came free with the
>                                 modem).
> Linksys BEFSR81 Router tied to a cable modem. All computers have
> 10/100 nics and can, once I puzzle out which computer has what
> address, ping each other. I have full CD's for all OS's and can
> compile stuff if a gun is pointed directly at my head. :-)
> a ======|R|
>              |O|
> b ======|U|==>cable modem ==>world
>              |T|
> c ======|E|
>              |R|

Remember, static servers make life easy.  And if you ever change
their IP, usually have to change some other settings at the same
time anyway.  So DHCP is NOT ideal for them.

But clients can be dynamic.  And both Samba and NFS will accomodate
nicely.  But Samba's dymanic NetBIOS resolution won't let you simply
ping the "name" -- as ping does NOT use Samba.  You must use
"smbclient" to access those dynamic NetBIOS names.

So the "workaround" is to use DHCP to assign static IPs to your
clients.  See if your router allows this.

-- TheBS

-- 
Bryan "TheBS" Smith     mailto:b.j.smith@ieee.org     chat:thebs413
Engineer   Absolute Value Systems, Inc.   http://www.linux-wlan.org
President     SmithConcepts, Inc.      http://www.SmithConcepts.com