在FreeBSD 7.2下安装Samba
1. Samba 安装
-----------------------------------------
Samba有二进制安装的版本, 也有源代码安装版本. 我用的系统是FreeBSD 7.2,
Samba的二进制安装并不支持FreeBSD. 所以, 我就选择了源代码安装方式.
我使用的samba版本是samba-3.4.3.tar.gz
1. Samba 安装
-----------------------------------------
Samba有二进制安装的版本, 也有源代码安装版本. 我用的系统是FreeBSD 7.2,
Samba的二进制安装并不支持FreeBSD. 所以, 我就选择了源代码安装方式.
我使用的samba版本是samba-3.4.3.tar.gz
#tar -zxvf samba-3.4.3.tar.gz
#cd samba-3.4.3/source3
#./configure
#make;make install
#cp ../examples/smb.conf.default /usr/local/samba/lib/smb.conf
#cd samba-3.4.3/source3
#./configure
#make;make install
#cp ../examples/smb.conf.default /usr/local/samba/lib/smb.conf
2、创建用户
-------------------------------------------
(1)samba用户管理使用smbpasswd和pdbedit命令
(2)samba认证使用的用户和组首先要在本地系统中存在
(3)samba只存储独立于本地系统的用户和口令信息,组则使用本地系统的组信息
-------------------------------------------
(1)samba用户管理使用smbpasswd和pdbedit命令
(2)samba认证使用的用户和组首先要在本地系统中存在
(3)samba只存储独立于本地系统的用户和口令信息,组则使用本地系统的组信息
#pw groupadd loggroup --创建系统本地组
#pw useradd -n weblog -g loggroup -d /tmp/king -s /usr/sbin/nologin --创建系统用户
#/usr/local/samba/bin/smbpasswd -a weblog --将系统本地用户变成samba用户
#pw useradd -n weblog -g loggroup -d /tmp/king -s /usr/sbin/nologin --创建系统用户
#/usr/local/samba/bin/smbpasswd -a weblog --将系统本地用户变成samba用户
错误信息:
/libexec/ld-elf.so.1: Shared object "libtalloc.so.1" not found,
/libexec/ld-elf.so.1: Shared object "libtalloc.so.1" not found,
解决办法:
cp /tmp/samba-3.4.3/source3/bin/* /usr/local/lib/
cp /tmp/samba-3.4.3/source3/bin/* /usr/local/lib/
3. 配置Samba
------------------------------------
#vi /usr/local/samba/lib/smb.conf
[king]
path = /tmp/king
valid users = @loggroup
read list = @loggroup
write list = @loggroup
security = user
encrypt passwords = yes
smb passwd file = /usr/local/samba/private/passdb.tdb
------------------------------------
#vi /usr/local/samba/lib/smb.conf
[king]
path = /tmp/king
valid users = @loggroup
read list = @loggroup
write list = @loggroup
security = user
encrypt passwords = yes
smb passwd file = /usr/local/samba/private/passdb.tdb
chmod -R 777 /tmp/king
4.启动samba
--------------------------------------
/usr/local/samba/sbin/smbd -D &
/usr/local/samba/sbin/nmbd -D &
5.自动运行samba
------------------
有两种方法:
(1)在/etc/rc.local加入以下内容:
/usr/local/samba/sbin/smbd -D &
/usr/local/samba/sbin/nmbd -D &
(2)在/etc/inetd.conf中加入以下内容:
netbios-ssn stream tcp nowait root /usr/local/samba/sbin/smbd -D smbd
netbios-ns dgram udp wait root /usr/local/samba/sbin/nmbd -D nmbd
swat stream tcp nowait/400 root /usr/local/samba/sbin/swat swat
第二种方法要保证inetd正常运行.
------------------
有两种方法:
(1)在/etc/rc.local加入以下内容:
/usr/local/samba/sbin/smbd -D &
/usr/local/samba/sbin/nmbd -D &
(2)在/etc/inetd.conf中加入以下内容:
netbios-ssn stream tcp nowait root /usr/local/samba/sbin/smbd -D smbd
netbios-ns dgram udp wait root /usr/local/samba/sbin/nmbd -D nmbd
swat stream tcp nowait/400 root /usr/local/samba/sbin/swat swat
第二种方法要保证inetd正常运行.
6.SWAT管理
---------------------------------------------------
默认情况下SWAT已被安装.
我试过通过执行/usr/local/samba/sbin/swat启动SWAT没有成功, 只有通过inetd.conf才可以成功启动.
启动成功后可以通过[url]http://samba_server_ip:901/[/url]访问SWAT管理页面.
默认情况, SWAT使用本地系统的root用户作为管理帐号. 注意, 是系统用户, 不是samba的共享用户.
7.检查服务是否正常
----------------------------------------------------
freebsd# netstat -an
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 172.16.16.151.445 172.16.16.150.1667 ESTABLISHED
tcp4 0 0 *.139 *.* LISTEN
tcp4 0 0 *.445 *.* LISTEN
tcp6 0 0 *.139 *.* LISTEN
tcp6 0 0 *.445 *.* LISTEN
udp4 0 0 172.16.16.151.138 *.*
udp4 0 0 172.16.16.151.137 *.*
udp4 0 0 *.138 *.*
udp4 0 0 *.137 *.*
----------------------------------------------------
freebsd# netstat -an
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 0 0 172.16.16.151.445 172.16.16.150.1667 ESTABLISHED
tcp4 0 0 *.139 *.* LISTEN
tcp4 0 0 *.445 *.* LISTEN
tcp6 0 0 *.139 *.* LISTEN
tcp6 0 0 *.445 *.* LISTEN
udp4 0 0 172.16.16.151.138 *.*
udp4 0 0 172.16.16.151.137 *.*
udp4 0 0 *.138 *.*
udp4 0 0 *.137 *.*
8.PF端口放行
---------------------------------------------------
#vi /etc/pf.conf
---------------------------------------------------
#vi /etc/pf.conf
table <gm> {172.16.1.0/24}
pass in quick inet proto tcp from <gm> to $ext_if port 139
pass in quick inet proto tcp from <gm> to $ext_if port 445
pass in quick inet proto udp from <gm> to $ext_if port 137
pass in quick inet proto udp from <gm> to $ext_if port 138
pass in quick inet proto tcp from <gm> to $ext_if port 139
pass in quick inet proto tcp from <gm> to $ext_if port 445
pass in quick inet proto udp from <gm> to $ext_if port 137
pass in quick inet proto udp from <gm> to $ext_if port 138