Showing posts with label samba. Show all posts
Showing posts with label samba. Show all posts

Tuesday, 17 April 2007

find out the IP of a Windows machine in a samba network

We all know that with DNS, we can easily find out the IP of a machine with an FQDN (i.e., fully qualified domain name). The commands like ping, nslookup (obsolete), dig, ... can be used for this purpose.

Additioanlly on Unix the file /etc/hosts can also be used to store information for machine names <-> IP addresses translations. The Windows equivelant file is usually C:\Windows\system32\drivers\etc\hosts.

But what about name resolution with WINS? Is there any simple comamnd to dig out the IP address of a Windows machine over network?

The answer is yes (of course). In a Windows network, there must exist at least one machine functions as a browser which keeps the information who is who.

On a *nix machine where samba is running, you can use the command smbtree to list all Windows shares over network, including Windows machine names. In particular, you can use command nmblook command to find out the IP of a windows machine, e.g.:

nmblook windozebox

to get the IP of the quoted windows box, just like nslookup for name resolution with DNS.

On a Windows 2K/XP machine, you can use the command net to dig out a lot of network information, for example, net view tells you avaliable Windows/Samba machines on the local network block. And you can use the ping command to find out a windows machine's IP even it has no dns record.

Friday, 23 March 2007

samba for time synchronization

A somewhat hidden feature of Samba is that you can use Samba as a local timeserver for your Windows clients. The following line is added to enable this feature. By default, a windows client will talk to a micro$oft time server if time synchronization is enabled. So now you can let those clients in LAN talk to the samba server with the following setting in the samba configuration file:

timeserver = yes



samba: use of netbios name and aliases

In samba configuration file, /etc/samba/smb.conf, I generally add these options,

 netbios name = linux
netbios aliases = debian ubuntu

Then I can have different virtual samba servers, just like virtual web servers with apache. Isn’t it cool?

Using the apache analogy, the netbios name = option is set the default samba host, whilst the netbios aliases = option is to setup additional virtual hosts. samba can have different controls for these virtual hosts.

In a cooperate environment, the best strategy is to set a samba share service bind to the service name (e.g., file-server, public-library, etc), not to the machine name that actually serves the file-sharing, so that when the machine is replaced or gone away, the file-sharing services can be still remains the same.

samba: secure your home shares

Usually I add the following two options for home share on a samba server, to tighten up the security:

[homes]
...
valid users = %S
path = /home/%S

The first option is to set, say user1, to only see his own home directory as the home share (he can see other public shares as well), not to see the home directory of user2.

The second option limits that the home directory of, say user1, as the share, must be /home/user1. For example, usually root’s home directory on many linux distros is /root, therefore it can not be accessed as the samba home share.