Sunday, 11 November 2007

SMB:Configuring your computer as a server

A fairly comprehensive graphical Samba configuration tool is available for KDE, by installing the "kdenetwork-filesharing" package. Once install, you can find it by launching the KDE Control Center. (Alt-F2 and then type kcontrol). Browse to Internet & Network > Samba. It is fairly easy to use.

A less friendly but also graphical tool is Swat, a web-based interface.

The following tips show how to do some basic things without installing additional software, using the command line. It is not difficult, just be careful with typos.

First open a terminal: Applications > System Tools > Terminal and open the file smb.conf

sudo nano -w /etc/samba/smb.conf

How to Save: To save in nano use "ctrl/o" than "ctrl/x".

Tip: Replacing nano with gedit gives you a nice graphical editor.

The file *smb.conf* is divided in several sections:

Global Settings
Debugging/Accounting
Authentication
Printing
File sharing
Misc
Share Definitions

Let's start with Global Settings. Here you will see several lines, which you can also see in the graphical networktool like workgroup and wins server. If you changed everything to your liking already then you can skip this section, if not change to what you need. If you do not know what items mean, leave them be and read the [WWW] relevant part in the real Samba-howto instead of randomly changing them. It will save you trouble-shooting later.

The important part for us is File sharing. We need to change:

[homes]
comment = Home Directories
browseable = no

# By default, the home directories are exported read-only. Change next
# parameter to 'yes' if you want to be able to write to them.
writable = no

This describes your /home folder. Usually you want to share this folder in a home-environment, because these are the files you want to share. To do so, make the following changes:

[homes]
comment = Home Directories
browseable = yes

# By default, the home directories are exported read-only. Change next
# parameter to 'yes' if you want to be able to write to them.
writable = yes

This finishes sharing your /home folder. The last thing we need to do is fixing a user.

Add users who can access your shares with the 'smbpasswd' command.

sudo  smbpasswd -a username

New SMB password:
Retype new SMB password:
Added user username.

NOTE: the username used here should be a real user setup on your PC/Server. Reload Samba for every change to users/passwords or 'smb.conf'

sudo /etc/init.d/samba reload

That's the basis of Samba file-sharing. Please leave your comments about what else is needed here.

Back to top

Complicating things a little

We started with the base of Samba file-sharing. The above-mentioned items should be enough to get you started. Next we will add details that you might or might not need.

Back to top

If you have more the one networkcard

If you have more the one networkcard (or interface) then you have to define where you want Samba to run. In smb.conf under the [global] section, add:

"interfaces = 127.0.0.1, 192.168.0.31/24"
"bind interfaces only = yes"

The first address (127.0.0.1), is a loopback network connection (it's your own machine). The second address (192.168.0.31), is the address of the card you want Samba to run on, the second number (24) is the subnet default for a CLASS-C network. It may vary depending on your network.

With "bind interfaces only" you limit which interfaces on a machine will serve SMB requests.

You can limit which IP address can connect to your Samba server adding these lines:

"hosts allow = 127.0.0.1, 192.168.0.31, 192.168.0.32"
"hosts deny = 0.0.0.0/0"

The loopback address must be present in the first line. The second line deny access from all IP address not in the first line.

Back to top

Sharing CUPS Printers

If You would like to share Your printers make the following changes to Samba:

If not already done create the Samba-user You want the share to be used by.

In smb.conf uncomment and change the lines ending up with the following configuration:

########## Printing ##########

# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
load printers = yes

# [...] // Some BSD printing stuff, do not edit if You do not need to

# CUPS printing. See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
printing = cups
printcap name = cups

and in the Share Definitions section append and/or modify the [printers] part ending up like this:

# ======================= Share Definitions =======================
# [...] // File and Folder sharing, do not edit if You do not need to

[printers]
comment = All Printers
browseable = no
path = /tmp
printable = yes
public = yes
writable = no
create mode = 0700
printcap name = /etc/printcap
print command = /usr/bin/lpr -P%p -r %s
printing = cups

Some explanation what is done:

the [printers] part defines the default-behavior for all the printers that are mentioned in "printcap name". A sort of template how to create shares for these printers. This template is applied if "load printers" is set to true. For more detailed explanation refer to the Samba documentation.

And do not forget to reload Samba:

sudo /etc/init.d/samba reload

Back to top

3 comments:

Z. said...

大林,back to top链接不好使啊!^_^

SEO said...

专业从事组合式仓储货架、建材超市及仓储式超市货架设计、制造、安装、调试的企业,是国内最大的货架制造商之一。公司已承接近千座仓储货架工程的设计、制造和安装。
塑料托盘专业制造商—塑料托盘制造有限公司南京麦瑞欢迎您!南京麦瑞塑料托盘有限公司是国内最具影响的物流产品大型生产企业,主要生产的产品有塑料托盘,塑料卡板箱, ...
仓储笼采用优质钢材经冷扎硬化焊接而成,强度高、装载能力大,仓储笼可叠四层、实现仓储立体化,不同型号、不同规格的仓储笼承重为0.8t~2.0t。折叠式结构,装载、周转、存放 ...
南京麦瑞工业设备是专业工具柜制造商,我们精确的人机工程设计和高品质的要求保证了工具柜可以对用户的工具和物料安全合理的存储,包括SL系列工具柜、PL系列工具柜等, ...
户外钢制园林垃圾桶LDY系列, ◎室内钢制方形垃圾桶LDB系列. ◎户外钢制分类垃圾桶LDF系列, ◎室内钢制圆形垃圾桶LDA系列. ◎户外钢木垃圾桶LDG系列, ◎广告式垃圾桶 ...
根据不同的生产需求,工作台分为三大系列:钢制工作台、铝制工作台和非标工作台,钢制工作台主体框架采用钢制材料,铝制工作台主体框架采用标准铝制型材,非标工作台 ...

SEO said...

液压升降机,施工升降机,丝杆升降机,曲臂升降机,电动升降机

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter