Think I never mentioned it but I have a small home server, it was built with a c2d E6600, an Intel G965 mobo and some HDDs.
Since 2 weeks ago I was using Ubuntu then I decided it was time to try something better and more challenging than Ubuntu, my choice was CentOS.
Why use CentOS ? Because it’s one of the best
enterprise class distro with 7 years support and have a good ammount of interesting features like services GUI manager and iptables GUI.
I don’t consider myself a
Unix pro nor a noob but I’ve to say that the first touch with this distro wasn’t the best.
In fact I had lots of trouble trying to install CentOS from USB drive, after had lost 1 hour or so I took a DVD drive, burned the ISO on a DVD and installed from it.
When finally I was able to get into the OS the first thing I did was installing XRDP to remote control the machine from one of my other PCs.
I also installed Transmission torrent client, added some iptables rules and did some other things.
Everything was quite easy except the installation and configuration of Samba server, to be honest I didn’t remember well what I did to make it works on Ubuntu but here on CentOS it gave me some troubles.
Google this time wasn’t that helpful, there aren’t much info or guides about Samba on CentOS, so I think I should write here how I made it works.
First of all, we have to install Samba, open the terminal, get admin privileges and type: <pre name=“code” class"ruby"> yum install samba
When everything is installed you have to set permissions, the directory I want to be shared is /media/Data so: <pre name="code" class"ruby"> chmod a+w /media/Data chcon -t samba\_share\_t /media/Data
The next thing to do is tell Samba server you want to make this folder public in the LAN, so open the terminal and as admin edit the /etc/samba/smb.conf file.
I like gedit, so I typed: <pre name=“code” class"ruby"> gedit /etc/samba/smb.conf
Once the editor presents you the file you have to modify it by adding few things: <pre name="code" class"ruby"> [global] workgroup = your\_workgroup netbios name = name\_of\_the\_machine\_on\_the\_network server string = this\_should\_be\_optional # need for netbios informations sharing over the network wins support = Yes [Authentication] # this way samba will not ask for password to connect to the machine security = share #======================= Share Definitions ======================= # name of the share [Data] # path of the shared directory path = /media/Data writable = yes browsable = yes read only = No guest ok = yes public = yes create mask = 0666 directory mask = 0777
After than this to apply the changes you have to restart samba and net-bios services, to make it type in terminal: <pre name=“code” class"ruby"> /sbin/service smb start /sbin/service nmb start
Those two services are booth needed, the first one, Samba, makes possible directory, printers etc etc sharing while net-bios share important information (like net-bios machine name) over the network.
For instance, without net-bios service you could not type `\\my-server` in the address bar in Windows explorer and get the shared resources of this machine but you will have to write `\\ip-address-of-the-given-machine`.
So, if you ask me, is better to have both of them enabled.
If at the next reboot Samba and net-bios services don't start automatically check System–>Administration–>Services and start `smb` and `nmb`.
In case iptables firewall is enabled you should also add some rules, there should be some preconfigured ones for Samba, in case they aren't present the ports to open are the following: <pre name="code" class"ruby"> Samba: TCP 139 445 UDP 137 138 Samba Client: UDP 137 138
If using an headless server, the iptables rules are: <pre name=“code” class"ruby">-I INPUT -s 192.168.0.0/24 -p udp -m udp –dport 137 -j ACCEPT -I INPUT -s 192.168.0.0/24 -p udp -m udp –dport 138 -j ACCEPT -I INPUT -s 192.168.0.0/24 -p tcp -m state –state NEW -m tcp –dport 139 -j ACCEPT -I INPUT -s 192.168.0.0/24 -p tcp -m state –state NEW -m tcp –dport 445 -j ACCEPT
This way everyone in your network should be able to reach the shared folder and copy from / to files and folders.
I hope this small guide could be helpful to someone.