Difference between revisions of "Create network shares"
| Line 26: | Line 26: | ||
'''$''' sudo nano -w /etc/samba/smb.conf | '''$''' sudo nano -w /etc/samba/smb.conf | ||
=== /etc/samba/smb.conf === | === /etc/samba/smb.conf === | ||
| + | The following example is comprised of three sections: ''global'', ''private'' and ''public''. The ''global'' section below contains the master settings for the share. Be sure to replace ''CYBERTRON'' with the name of your domain and ''TELETRAN4'' with the name of your server. The "hosts allow" section allows connections from localhost and any IP address on the 192.168.0.x network, while the "hosts deny" section prevents connection from any IP extraneous to the local network. The share uses "user" based security, which will be explained in the next section. | ||
| + | <pre> | ||
| + | ####################### | ||
| + | # | ||
| + | # gr0x0rd's smb.conf | ||
| + | # | ||
| + | ####################### | ||
| + | |||
| + | [global] | ||
| + | workgroup = CYBERTRON | ||
| + | netbios name = TELETRAN4 | ||
| + | server string = Samba Server %v | ||
| + | printcap name = cups | ||
| + | printing = cups | ||
| + | load printers = no | ||
| + | log file = /var/log/samba/log.%m | ||
| + | max log size = 50 | ||
| + | socket options = TCP_NODELAY SO_RCVBUF=65536 SO_SNDBUF=65536 | ||
| + | interfaces = lo eth0 | ||
| + | bind interfaces only = yes | ||
| + | hosts allow = 127.0.0.1 192.168.0. | ||
| + | hosts deny = 0.0.0.0/0 | ||
| + | security = user | ||
| + | guest ok = yes | ||
| + | |||
| + | log level = 1 | ||
| + | read raw = yes | ||
| + | write raw = yes | ||
| + | oplocks = yes | ||
| + | max xmit = 65535 | ||
| + | dead time = 15 | ||
| + | getwd cache = yes | ||
| + | |||
| + | #vfs object = vscan-clamav | ||
| + | #vscan-clamav: config-file = /etc/samba/vscan-clamav.conf | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | [gr0x0rd] | ||
| + | comment = Cybertron Repository | ||
| + | valid users = gr0x0rd | ||
| + | browseable = yes | ||
| + | writeable = yes | ||
| + | public = no | ||
| + | create mode = 0766 | ||
| + | guest ok = no | ||
| + | path = /home/gr0x0rd/files | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | [teletran3] | ||
| + | comment = public | ||
| + | browseable = yes | ||
| + | writeable = no | ||
| + | public = no | ||
| + | create mode = 0766 | ||
| + | guest ok = no | ||
| + | path = /home/gr0x0rd/files | ||
| + | veto files = /home/gr0x0rd/files/gr0x-Z/ | ||
| + | </pre> | ||
Revision as of 15:06, 26 December 2010
You may have the need to share files and folders on your Gentoo PC with other files on the network. There are two primary ways of doing this, and these methods are using nfs or samba. Samba is geared towards compatibility with Microsoft Windows, whereas nfs is an abbreviation for network file system, and has its roots in the early days of unix.
On order to create a samba or nfs share, you'll need to make sure you have the proper kernel config. The necessary options are shown in the kernel section.
To create an nfs share, you'll first need to emerge the net-fs/nfs-utils package. This is ideal if you are wanting to share files between multiple linux systems. If there is a windows machine in the mix (including virtual machines) you will probably want to use samba.
$ sudo emerge -av nfs-utils
Once the package has been emerged, we can configure the exports, which are the folders we're sharing and the access level and permissions for clients. In the example below, we will share the folder /home/gr0x0rd to some other machines on the network.
$ sudo nano -w /etc/exports
/etc/exports
# /etc/exports: NFS file systems being exported. See exports(5). /home/gr0x0rd 192.168.0.100(rw,no_subtree_check) /home/gr0x0rd 10.10.3.119(rw,no_subtree_check)
Once you have saved your exports file, we can start the nfs server.
$ sudo /etc/init.d/nfs start
To start the nfs server with the system,
$ sudo rc-update add nfs default
You should now be able to mount the share from another machine on your network.
In order to share files with machines on your network running Microsoft Windows, you'll need to install and configure a Samba server. Before performing the emerge, be sure to check that you have the desired USE flags set.
$ sudo emerge -av samba
Once the emerge has completed, you will need to set up your shares. This is done by editing the file /etc/samba/smb.conf.
$ sudo nano -w /etc/samba/smb.conf
/etc/samba/smb.conf
The following example is comprised of three sections: global, private and public. The global section below contains the master settings for the share. Be sure to replace CYBERTRON with the name of your domain and TELETRAN4 with the name of your server. The "hosts allow" section allows connections from localhost and any IP address on the 192.168.0.x network, while the "hosts deny" section prevents connection from any IP extraneous to the local network. The share uses "user" based security, which will be explained in the next section.
####################### # # gr0x0rd's smb.conf # ####################### [global] workgroup = CYBERTRON netbios name = TELETRAN4 server string = Samba Server %v printcap name = cups printing = cups load printers = no log file = /var/log/samba/log.%m max log size = 50 socket options = TCP_NODELAY SO_RCVBUF=65536 SO_SNDBUF=65536 interfaces = lo eth0 bind interfaces only = yes hosts allow = 127.0.0.1 192.168.0. hosts deny = 0.0.0.0/0 security = user guest ok = yes log level = 1 read raw = yes write raw = yes oplocks = yes max xmit = 65535 dead time = 15 getwd cache = yes #vfs object = vscan-clamav #vscan-clamav: config-file = /etc/samba/vscan-clamav.conf
[gr0x0rd] comment = Cybertron Repository valid users = gr0x0rd browseable = yes writeable = yes public = no create mode = 0766 guest ok = no path = /home/gr0x0rd/files
[teletran3] comment = public browseable = yes writeable = no public = no create mode = 0766 guest ok = no path = /home/gr0x0rd/files veto files = /home/gr0x0rd/files/gr0x-Z/