Linux09【Samba服务器的相关配置】

1.设置虚拟机centos7的ip
    修改配置文件/etc/sysconfig/network-scripts/ifcfg-eth0(eth0,第一块网卡,如果是第二块则为eth1),保证主机虚拟机互相ping通
2.安装samba
    yum -y install samba samba-client samba-common
    命令rpm -qa | grep samba 查看已经安装的samba相关软件
3.创建用户
    添加用户 
    useradd xxx (userdel删除用户  usermod修改用户组 id xxx查看用户组情况 )
    添加samba密码
    smbpasswd -a xxx
4.创建共享文件夹
    mkdir -p /xxx
   修改文件夹权限
   chgrp xxx /xxx
   chown xxx /xxx
   chmod 770 /xxx
   (ls /xxx -l 查看文件夹权限)
5.修改samba配置文件
    备份原配置文件
   mv smb.conf smb.conf.bak 
   修改配置文件
   vi smb.conf
   清空并修改smb.conf内容
   [global]
        workgroup = WORKGROUP
        netbios name = xxx
        server string = Samba Server
        security = user
        map to guest = Bad Uesr
   [xxx]
        path = /xxx
        writable = yes
        browseable = yes
        guest ok = yes
        write list = @xxx
        validusers = @xxx
6.重启samba服务
    systemctl restart smb 
    systemctl reload smb
    systemctl status smb
7.关闭防火墙和SELinux
    关闭防火墙
    systemctl stop fitewalld
    systemctl disable firewalld
    关闭SELinux666666666666666666
    vi /etc/selinux/config 修改 SELINUX=disabled
8.设置开机启动samba
    chkconfig smb on

/etc/passwd的权限应该为644。


修改完后reboot重启

Centos7 关闭防火墙

CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下

1、直接关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、设置 iptables service

yum -y install iptables-services

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables 

增加规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。

Centos7 Firewalld 解决防火墙问题

** 
第一次使用Firewalld关了半天没关掉,之前一直使用iptables,从来没出现过这么挠头的问题。 
记录一下我解决端口不能访问的问题,其实思路很简单,卸载Firewalld安装iptables 
一步一步来说吧 
1. Disable Firewalld Service.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl mask firewalld

2. Stop Firewalld Service.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl stop firewalld

3. Install iptables service related packages.

[root@rhel-centos7-tejas-barot-linux ~]# yum -y install iptables-services

4. Make sure service starts at boot:

[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable iptables

[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable ip6tables

5. Now, Finally Let’s start the iptables services.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl start iptables

[root@rhel-centos7-tejas-barot-linux ~]# systemctl start ip6tables

安装iptables 已经完成了这个时候iptables已经能用了。 
但是您的Firewalld 还在runing。不信您可以查看一下 
firewall-cmd –state 
好了不废话了,直接yum remove firewalld 
终于卸载了……………………….. 
好了你可以使用iptables了,尽情使用吧。 
如果您连iptables也不想用了那就使用 
service iptables stop命令关闭吧。


猜你喜欢

转载自blog.csdn.net/qq_37311616/article/details/80315526