1. swat介绍
SWAT:The Samba WEB Administration Tool
SWAT是Samba的图形化管理工具。我们可以通过浏览器利用swat工具来设置samba。在swat中每一个samba参数都有相应的帮助文件或解释文件,很适合初学者。
SWAT工具嵌套在xinetd超级守护进程中,要通过启用xinetd进程来启用swat。因此要先安装xinetd工具包,然后安装swat工具包。
2. 安装xinetd
如图一,查看系统是否安装了xinetd工具包。
图一:查看系统是否安装了xinetd
如果未安装,挂载系统盘安装即可。
[root@RHEL5 /]#mount /dev/cdrom /mnt/cdrom
[root@RHEL5 /]#rpm –ivh /mnt/cdrom/Servers/xinetd-2.3.14- 10.el5.i386.rpm
3. 安装swat
如图二,查看系统是否安装了swat工具包。
[root@RHEL5 /]#rpm –qa |grep swat
图二:查看系统是否安装了swat
如果未安装,挂载系统盘安装即可。
[root@RHEL5 /]#rpm –ivh /mnt/cdrom/Servers/samba-swat-3.0.28-0.el5.8.i386.rpm
4. 编辑swat配置文件
因为swat是xinetd超级守护进程的一个子进程,所以swat工具配置文件在xinetd目录中。我们要设置swat配置文件,开启此子进程,以便在启用xinetd进程是来启用swat。swat配置文件在/etc/xinetd.d目录中。
如图三,在xinetd.d目录中查看swat文件。
图三:swat配置文件在xinetd.d目录下
如图四:编辑swat配置文件。
① 将“only_from=127.0.0.1”改成“only_from=0.0.0.0”,这样该服务器就可以监听所有的来访IP。
② 将“disable=yes”改成“disable=no”,这样swat子进程就可以随xinetd超级守护进程一起启动了。可以吃用chkconfig命令查看swat是否启用了。
③ swat默认使用tcp的901端口。“port=901”,可以修改。
④ 通过web来配置samba,默认使用root账号进入。“user=root”,可以修改成其他的系统用户。
⑤ swat的执行程序默认在/usr/sbin目录下。

图四:编辑后的swat配置文件
如图五,查看系统的services中是否将tcp的901添加了进去。
图五:在/etc/services中查看tcp901
如果/etc/services文件中没有tcp901,那么就编辑该文件,添加“swat 901/tcp”即可。
5. 启动swat
因为swat是xinetd的子进程,所以只要启用了xinetd,那么swat也就会伴随xinetd启动。
图六:重启xinetd
图七:使用chkconfig查看swat状态
6. 防火墙设置
关闭防火墙或者开启swat相关端口。
【关闭防火墙】
[root@RHEL5 /]#service iptables stop
【开启swat901端口,直接写入INPUT链,重启iptables会丢失】
[root@RHEL5 /]#iptables -I INPUT -p tcp --dport 901 -j ACCEPT
【开启swat901端口,通过编辑“RH-Firewall-1-INPUT”自定义链来打开,配置不会丢失】
[root@RHEL5 /]#vi /etc/sysconfig/iptables
加入:-A RH-Firewall-1-INPUT -p tcp --dport 901 -j ACCEPT
【关闭SELinux】
[root@RHEL5 /]#vi /etc/sysconfig/selinux
设置“SELINUX=disabled”
7. 使用web登入SWAT
如果访问swat的端口没有改变,那么通过web登入的方式就是:[url]http://192.168.120.241:901[/url]。
图八:登入swat,注意加默认端口901
然后输入用户名和密码,如果进入swat的用户没有改变,那么默认就是root账号。
图九:输入有权访问swat的账号,默认为root
正常进入swat的登陆页面,可以看到有8个选项。
图十:swat页面格式
8. 通过swat配置samba
在swat页面我们可以看到有8个选项,每个选项可以配置samba的不同功能。
HOME:Samba相关程序及文件说明。
GLOBALS:设置Samba的全局参数。
SHARES:设置Samba的共享参数。
PRINTERS:设置Samba的打印参数。
WIZARD:Samba配置向导。
STATUS:查看和设置Samba的服务状况。
VIEW:查看Samba的文本配置文件,即smb.conf。
PASSWORD:设置Samba用户,可以修改密码,新建删除用户。
① HOME:介绍Samba的相关程序和文件及其使用方法
Daemons:进程,service smb start启动smbd和nmbd。
smbd - the SMB daemon
nmbd - the NetBIOS nameserver
winbindd - the winbind daemon
Configuration Files:配置文件,默认在/etc/samba目录下
smb.conf - the main Samba configuration file
lmhosts - NetBIOS hosts file
smbpasswd - SMB password file
Administrative Utilities:Samba管理工具
smbcontrol - send control messages to Samba daemons
smbpasswd - managing SMB passwords
SWAT - web configuration tool
net - tool for administration of Samba and remote CIFS servers
pdbedit - Samba user account management tool
tdbbackup - Tool for backing up TDB databases
Client Tools:Samba客户端工具
rpcclient - command line MS-RPC client
smbtar - SMB backup tool
smbclient - command line SMB client
smbmnt - helper utility for mounting SMB filesystems on Linux hosts
smbmount - user space tool for mounting SMB filesystems under Linux
smbumount - user space tool for umounting SMB filesystems under Linux
ntlm_auth - allow external programs to use NTLM authentication
smbcquotas - get or set quotas on NTFS 5 shares
smbspool - Send a print job to an SMB printer
smbtree - Text-based SMB network browsing
Diagnostic Utilities:Samba测试工具
smbstatus - monitoring Samba
testparm - validating your config file
nmblookup - NetBIOS name query tool
wbinfo - Tool for getting winbind information
Misc. Utilities:其他工具
profiles - migrating profiles from one domain to another
log2pcap - generate pcap files from samba log files
② GLOBALS:设置Samba的全局参数,即smb.conf文件的[global]。
在GLOBALS中,分为Basic(基本的)和Advanced(高级的,完全的)两个选项。
图十一:GLOBALS选项的Basic和Advanced子选项
在Basic选项中可以设置Samba的基本参数。
在每个参数项中有很多的参数可以设置。
Base Options:基础选项
Secutity Options:安全选项
Logging Options:日志选项