System: CentOS 6.8
SELinux: Off
Iptables: Open
Samba Service Requirements:
Login with username/password, have read and write access.
SELinux settings
# Setenforce 0
# sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config
Iptables settings (refer to Http://man.linuxde.net/iptables)
# iptables-i Input 5-m State--state new-m tcp-p TCP--dport 139-j ACCEPT
# iptables-i input 5-m State--state New-m tcp-p TCP--dport 445-j ACCEPT
# iptables-i INPUT 5-p udp-m UDP--dport 137-j ACCEPT
# iptables-i in Put 5-p udp-m UDP--dport 138-j ACCEPT
# iptables-save >/home/iptables.save
# iptables-restore </HOME/IP Tables.save
# iptables-l-N
To prevent firewall rules from returning to the default after the Iptables rule restarts the service or machine, modify the iptables configuration file
# Cat/etc/sysconfig/iptables
# Firewall configuration written by System-config-firewall
# Manual Customization to this file is not recommended.
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m State--state Establi Shed,related-j ACCEPT
-a input-p icmp-j ACCEPT-a
input-i lo-j ACCEPT
-a input-m state--state new-m TC P-p TCP--dport 22-j ACCEPT
-a input-p tcp-m state--state new-m TCP--dport 445-j ACCEPT
-a Input-p TCP- M state--state new-m TCP--dport 139-j ACCEPT
-a input-p udp-m UDP--dport 138-j
-a ACCEPT input-p UDP--dport 137-j ACCEPT
-a input-j REJECT--reject-with
-icmp-host-prohibited-a forward-j REJECT--reject-w ITH icmp-host-prohibited
COMMIT
Samba Service Installation
# yum-y Install Samba samba-client samba-common
installed:
samba.x86_64 0:3.6.23-45.el6_9 samba-client.x86_64 0:3.6.23-45.el6_9
samba-common.x86_64 0:3.6.23-45.el6_9
is installed as a dependency:
samba-winbind.x86_64 0:3.6.23-45. El6_9 samba-winbind-clients.x86_64 0:3.6.23-45.el6_9
Create users, groups, and modify permissions for the Samba service (Samba home directory:/home/samba, user name: SMB, Group: SMB); Set up boot service
# groupadd SMB
# useradd smb-d/home/smb/-G smb-s/sbin/nologin
# chown-r smb:smb/home/smb/
# SMBPASSWD- A SMB
# chkconfig NMB on
# chkconfig SMB on
Start a service
#/ETC/INIT.D/SMB Start #
/ETC/INIT.D/NMB start
# ss-tnl|grep:139
LISTEN 0 *:139 *:*
LISTEN 0 :: 139 :::*
# ss-tnl|grep:445
LISTEN 0 *:445 *:*
LISTEN 0 :: 445 :::*
Verify
Last attached smb.conf file
# cat/etc/samba/smb.conf|grep-v ' # ' [global] workgroup = MyGroup Server string = Samba server Version%v; NetBIOS name = MYSERVER; Interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24; Hosts allow = 127.
192.168.12.192.168.13. Log file =/var/log/samba/log.%m Max log size = Security = User Passdb backend = Tdbsam; Security = domain; Passdb backend = Tdbsam; realm = My_realm; Password Server = <NT-Server-Name>; Security = user; Passdb backend = Tdbsam; Domain master = yes; Domain logons = yes; logon script =%m.bat; logon script =%u.bat; Logon path = \\%l\profiles\%u; Logon path =; Add User script =/usr/sbin/useradd "%u"-n-g users; Add Group script =/usr/sbin/groupadd "%g"; Add Machine script =/usr/sbin/useradd-n-C "Workstation (%u)"-m-d/nohome-s/bin/false "%u"; Delete user script =/usr/sbin/userdel "%u"; Delete user from group script =/usr/sbin/useRdel "%u" "%g"; Delete Group script =/usr/sbin/groupdel "%g"; Local master = no; OS level = 33; Preferred Master = yes; WINS support = yes; WINS Server = w.x.y.z; WINS proxy = yes; DNS proxy = yes load printers = yes cups options = raw; Printcap name =/etc/printcap; Printcap name = Lpstat; printing = cups; Map archive = no; Map hidden = no; Map Read Only = no; Map system = no; Store DOS attributes = yes [homes] comment = home directories browseable = no writable = yes; Valid users =%s; Valid users = mydomain\%s [printers] comment = all printers Path =/var/spool/samba browseable = no guest OK = no writable = no printable = yes; [Netlogon]; Comment = Network Logon Service; Path =/var/lib/samba/netlogon; Guest OK = yes; writable = no; Share modes = no; [Profiles]; Path =/var/lib/samba/profiles; browseable = no; Guest OK = yes; [Public]
; Comment = Public Stuff; Path =/home/samba; public = yes; writable = yes; printable = no;
Write list = +staff