samba服务器的搭建

环境:windows 7 + VmwarePlayer6.0 + fedora 18 + samba4.0.9

一、windows访问linux共享文件

Wmware网卡连接方式为Bridged

windows与linux之间ping是互通的

[root@localhost ~]# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 8  bytes 616 (616.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 616 (616.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

p3p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.105  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::20c:29ff:fe1a:f593  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:1a:f5:93  txqueuelen 1000  (Ethernet)
        RX packets 1030  bytes 92020 (89.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 591  bytes 77045 (75.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  base 0x2000

安装samba软件

yum install samba

查看是否安装

rpm -qa

system-config-samba-1.2.100-1.fc18.noarch ----这是一个图形界面配置samba服务软件(yum install system-                                                                                      config-samba)
samba-4.0.9-1.fc18.i686
samba-common-4.0.9-1.fc18.i686
samba-libs-4.0.9-1.fc18.i686
samba-client-4.0.9-1.fc18.i686

设置selinux为disable

vi /etc/sysconfig/selinux 编辑  SELINUX=disabled 或者是

[root@localhost ~]# setenforce 0     下次重启会失效
setenforce: SELinux is disabled
通过getenforece命令查看是否关闭

[root@localhost ~]# getenforce
Disabled  

设置iptables 

[root@localhost ~]# iptables -L INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
2    ACCEPT     all  --  anywhere             anywhere
3    INPUT_direct  all  --  anywhere             anywhere
4    INPUT_ZONES  all  --  anywhere             anywhere
5    ACCEPT     icmp --  anywhere             anywhere
6    REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited
[root@localhost ~]# iptables -D INPUT 6
[root@localhost ~]# iptables -L INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
2    ACCEPT     all  --  anywhere             anywhere
3    INPUT_direct  all  --  anywhere             anywhere
4    INPUT_ZONES  all  --  anywhere             anywhere
5    ACCEPT     icmp --  anywhere             anywhere

保存iptables设置(保存过后下次重启还是没有生效,不知到为什么,有清楚的还望不吝赐教

[root@localhost ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

所以使用firewall-config永久配置允许samba服务

samba服务器的搭建_第1张图片

share模式(不需要认证)

[root@localhost ~]# cat /etc/samba/smb.conf
[global]
        workgroup = workgroup
        server string = sambaserver
        netbios name = wph
        security = share
[file]
        comment = home directories
        path = /filesever
        public = yes
        writeable = yes
启动samba服务

service smb start

service nmb start

windows 运行 \\192.168.1.105

samba服务器的搭建_第2张图片

user模式(需要认证)

[root@localhost samba]# smbpasswd -a wph
New SMB password:
Retype new SMB password:
Added user wph.

[root@localhost samba]# cat smb.conf
[global]
        workgroup = workgroup
        server string = sambaserver
        netbios name = wph
        security = user
[user]
        comment = user
        path = /myfile/
        valid users = wph
        writeable = yes

改变共享目录的用户组

[root@localhost ~]# chown wph /myfile
[root@localhost ~]# ls -ld /myfile/
drwxrwxrwx 2 wph root 4096 Sep 19 00:46 /myfile/

[root@localhost samba]# service smb restart
Redirecting to /bin/systemctl restart  smb.service

windows 运行 \\192.168.1.105


samba服务器的搭建_第3张图片

你可能感兴趣的:(samba)