Rete mista con linux,windows

  1. Intro
  2. Configurazione samba
  3. Configurazione cups

Intro

Con questa guida vediamo come metter su una piccola rete

mista con macchina linux che farà da servente principale,e 2

clienti uno windows e l'altro linux.

Sulla macchina linux gireranno i servizi cups e samba,mentre

nel cliente windows lasciamo tutto come è,nel cliente linux gireranno cups e samba.

Tutte le macchine hanno ip statico 192.168.0.* e abbiamo

Server linux 192.168.0.2 che chiameremo Server

Client windows 192.168.0.3 che chiameremo Client1

Client linux 192.168.0.4 che chiameremo Client2

Configurazione Samba

Nel server linux prendiamo come esempio questo file di configurazione /etc/samba/smb.conf

# This is the main Samba configuration file. You should read the

# smb.conf(5) manual page in order to understand the options listed

# here. Samba has a huge number of configurable options (perhaps too

# many!) most of which are not shown in this example

#

# For a step to step guide on installing, configuring and using samba,

# read the Samba-HOWTO-Collection. This may be obtained from:

# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf

#

# Many working examples of smb.conf files can be found in the

# Samba-Guide which is generated daily and can be downloaded from:

# http://www.samba.org/samba/docs/Samba-Guide.pdf

#

# Any line which starts with a ; (semi-colon) or a # (hash)

# is a comment and is ignored. In this example we will use a #

# for commentry and a ; for parts of the config file that you

# may wish to enable

#

# NOTE: Whenever you modify this file you should run the command "testparm"

# to check that you have not made any basic syntactic errors.

#

#======================= Global Settings =====================================

[global]

# workgroup = NT-Domain-Name or Workgroup-Name, eg: LINUX2

workgroup = WORKGROUP

# server string is the equivalent of the NT Description field

server string = Linux64

# Security mode. Defines in which mode Samba will operate. Possible

# values are share, user, server, domain and ads. Most people will want

# user level security. See the Samba-HOWTO-Collection for details.

security = user

# This option is important for security. It allows you to restrict

# connections to machines which are on your local network. The

# following example restricts access to two C class networks and

# the "loopback" interface. For more examples of the syntax see

# the smb.conf man page

hosts allow = 192.168.0.*

# If you want to automatically load your printer list rather

# than setting them up individually then you'll need this

load printers = yes

# you may wish to override the location of the printcap file

printcap name = /etc/printcap

# on SystemV system setting printcap name to lpstat should allow

# you to automatically obtain a printer list from the SystemV spool

# system

; printcap name = lpstat

# It should not be necessary to specify the print system type unless

# it is non-standard. Currently supported print systems include:

# bsd, cups, sysv, plp, lprng, aix, hpux, qnx

printing = cups

# Uncomment this if you want a guest account, you must add this to /etc/passwd

# otherwise the user "nobody" is used

; guest account = pcguest

# this tells Samba to use a separate log file for each machine

# that connects

log file = /var/log/samba/samba.%m

# Put a capping on the size of the log files (in Kb).

max log size = 50

# Use password server option only with security = server

# The argument list may include:

# password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]

# or to auto-locate the domain controller/s

# password server = *

; password server = <NT-Server-Name>

# Use the realm option only with security = ads

# Specifies the Active Directory realm the host is part of

; realm = MY_REALM

# Backend to store user information in. New installations should

# use either tdbsam or ldapsam. smbpasswd is available for backwards

# compatibility. tdbsam requires no further configuration.

; passdb backend = tdbsam

# Using the following line enables you to customise your configuration

# on a per machine basis. The %m gets replaced with the netbios name

# of the machine that is connecting.

# Note: Consider carefully the location in the configuration file of

# this line. The included file is read at that point.

; include = /usr/local/samba/lib/smb.conf.%m

# Configure Samba to use multiple interfaces

# If you have multiple network interfaces then you must list them

# here. See the man page for details.

; interfaces = 192.168.12.2/24 192.168.13.2/24

# Browser Control Options:

# set local master to no if you don't want Samba to become a master

# browser on your network. Otherwise the normal election rules apply

; local master = no

# OS Level determines the precedence of this server in master browser

# elections. The default value should be reasonable

; os level = 33

# Domain Master specifies Samba to be the Domain Master Browser. This

# allows Samba to collate browse lists between subnets. Don't use this

# if you already have a Windows NT domain controller doing this job

; domain master = yes

# Preferred Master causes Samba to force a local browser election on startup

# and gives it a slightly higher chance of winning the election

; preferred master = yes

# Enable this if you want Samba to be a domain logon server for

# Windows95 workstations.

; domain logons = yes

# if you enable domain logons then you may want a per-machine or

# per user logon script

# run a specific logon batch file per workstation (machine)

; logon script = %m.bat

# run a specific logon batch file per username

; logon script = %U.bat

# Where to store roving profiles (only for Win95 and WinNT)

# %L substitutes for this servers netbios name, %U is username

# You must uncomment the [Profiles] share below

; logon path = \\%L\Profiles\%U

# Windows Internet Name Serving Support Section:

# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server

; wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client

# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both

; wins server = w.x.y.z

# WINS Proxy - Tells Samba to answer name resolution queries on

# behalf of a non WINS capable client, for this to work there must be

# at least one WINS Server on the network. The default is NO.

; wins proxy = yes

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names

# via DNS nslookups. The default is NO.

dns proxy = no

# These scripts are used on a domain controller or stand-alone

# machine to add or delete corresponding unix accounts

; add user script = /usr/sbin/useradd %u

; add group script = /usr/sbin/groupadd %g

; add machine script = /usr/sbin/adduser -n -g machines -c Machine -d /dev/null -s /bin/false %u

; delete user script = /usr/sbin/userdel %u

; delete user from group script = /usr/sbin/deluser %u %g

; delete group script = /usr/sbin/groupdel %g

#============================ Share Definitions ==============================

# Un-comment the following and create the netlogon directory for Domain Logons

; [netlogon]

; comment = Network Logon Service

; path = /usr/local/samba/lib/netlogon

; guest ok = yes

; writable = no

; share modes = no

# Un-comment the following to provide a specific roving profile share

# the default is to use the user's home directory

;[Profiles]

; path = /usr/local/samba/profiles

; browseable = no

; guest ok = yes

# NOTE: If you have a BSD-style print system there is no need to

# specifically define each individual printer

[printers]

comment = All Printers

path = /var/spool/samba

security = server

browseable = no

public = yes

guest ok = no

writable = no

printable = yes

create mode = 0700

print command = lpr -r -h -P %p %s

[Esempio]

comment = Esempio

path = /home/utente/esempio

valid users = utente1 utente2

public = no

writable = yes

printable = no

create mask = 0765

Notate in particolare

workgroup=WORKGROUP abbiamo scelto il nome usato da Windows*,ma potete cambiarlo,ovviamente

è più comodo se tutti e 3 clienti usano lo stesso gruppo di lavoro.

security = user chiederà la password per ogni accesso

hosts allow = 192.168.0.* ammetterà esclusivamente macchine con indirizzi 192.168.0.*

[Esempio]

comment = Esempio

path = /home/utente/esempio

valid users = utente1 utente2

public = no

writable = yes

printable = no

create mask = 0765

Questa è la condivisione del server,gli utenti accederanno previa autenticazione alla condivisione home/utente/esempio con permessi lettura e

scrittura.Inutile dire che questi utenti dovranno essere presenti sul server e su samba,quindi daremo sul Server

# adduser utente1
# adduser utente 2
# smbpasswd -a utente1

ovviamente utente1 e utente2 sono solo di esempio,mettete i nomi ai quali volete dare l'accesso alle risorse condivise.

Accedere alle risorse condivise è semplicissimo:da Windows andate su "Risorse di rete" e cliccate sul gruppo di lavoro(WORKGROUP in questo

esempio) poi sul nome del "pc" che in questo caso è Linux64 autenticatevi con il nome utente e la password che avrete già impostato sul server con

adduser e smbpass.

Da linux abbiamo 2 modi,da linea di comando e via grafica con Dolphin sotto Kde4,con dolphin la procedura è identica a windows,ma se

proprio non va usate la stringa smb://192.168.0.2/

Da linea di comando invece

$ smbclient -L 192.168.0.2

e vi verranno mostrate tutte le condivisioni

# smbclient \\\\192.168.0.2\\Nomecondivisione

e accederete alla condivisione mediante un client ftp.

Configurazione Cups

Sul server editiamo i seguenti files di testo

/etc/cups/mime.convs

#

# "$Id: mime.convs.in 8676 2009-05-22 19:30:50Z mike $"

#

# DO NOT EDIT THIS FILE, AS IT IS OVERWRITTEN WHEN YOU INSTALL NEW

# VERSIONS OF CUPS. Instead, create a "local.convs" file that

# reflects your local configuration changes.

#

# MIME converts file for the Common UNIX Printing System (CUPS).

#

# Copyright 2007-2009 by Apple Inc.

# Copyright 1997-2007 by Easy Software Products.

#

# These coded instructions, statements, and computer programs are the

# property of Apple Inc. and are protected by Federal copyright

# law. Distribution and use rights are outlined in the file "LICENSE.txt"

# which should have been included with this file. If this file is

# file is missing or damaged, see the license at "http://www.cups.org/".

#

########################################################################

#

# Format of Lines:

#

# source/type destination/type cost filter

#

# General Notes:

#

# The "cost" field is used to find the least costly filters to run

# when converting a job file to a printable format.

#

# All filters *must* accept the standard command-line arguments

# (job-id, user, title, copies, options, [filename or stdin]) to

# work with CUPS.

#

########################################################################

#

# PostScript filters

#

application/pdfapplication/vnd.cups-postscript66pdftops

application/postscriptapplication/vnd.cups-postscript66pstops

application/vnd.hp-HPGLapplication/postscript66hpgltops

application/x-cshellapplication/postscript33texttops

application/x-csourceapplication/postscript33texttops

application/x-perlapplication/postscript33texttops

application/x-shellapplication/postscript33texttops

text/plainapplication/postscript33texttops

text/htmlapplication/postscript33texttops

image/gifapplication/vnd.cups-postscript66imagetops

image/pngapplication/vnd.cups-postscript66imagetops

image/jpegapplication/vnd.cups-postscript66imagetops

image/tiffapplication/vnd.cups-postscript66imagetops

image/x-bitmapapplication/vnd.cups-postscript66imagetops

image/x-photocdapplication/vnd.cups-postscript66imagetops

image/x-portable-anymapapplication/vnd.cups-postscript66imagetops

image/x-portable-bitmapapplication/vnd.cups-postscript66imagetops

image/x-portable-graymap application/vnd.cups-postscript66imagetops

image/x-portable-pixmapapplication/vnd.cups-postscript66imagetops

image/x-sgi-rgbapplication/vnd.cups-postscript66imagetops

image/x-xbitmapapplication/vnd.cups-postscript66imagetops

image/x-xpixmapapplication/vnd.cups-postscript66imagetops

#image/x-xwindowdumpapplication/vnd.cups-postscript66imagetops

image/x-sun-rasterapplication/vnd.cups-postscript66imagetops

########################################################################

#

# Form filter...

#

# This filter does not currently exist, but the file format is defined

# in the IDD and registered with the IANA for future use...

#

#application/vnd.cups-form application/vnd.cups-postscript 33 formtops

########################################################################

#

# Raster filters...

#

image/gifapplication/vnd.cups-raster100imagetoraster

image/pngapplication/vnd.cups-raster100imagetoraster

image/jpegapplication/vnd.cups-raster100imagetoraster

image/tiffapplication/vnd.cups-raster100imagetoraster

image/x-bitmapapplication/vnd.cups-raster100imagetoraster

image/x-photocdapplication/vnd.cups-raster100imagetoraster

image/x-portable-anymapapplication/vnd.cups-raster100imagetoraster

image/x-portable-bitmapapplication/vnd.cups-raster100imagetoraster

image/x-portable-graymap application/vnd.cups-raster100imagetoraster

image/x-portable-pixmapapplication/vnd.cups-raster100imagetoraster

image/x-sgi-rgbapplication/vnd.cups-raster100imagetoraster

image/x-xbitmapapplication/vnd.cups-raster100imagetoraster

image/x-xpixmapapplication/vnd.cups-raster100imagetoraster

#image/x-xwindowdumpapplication/vnd.cups-raster100imagetoraster

image/x-sun-rasterapplication/vnd.cups-raster100imagetoraster

# pstoraster is part of GPL Ghostscript...

application/vnd.cups-postscriptapplication/vnd.cups-raster100pstoraster

########################################################################

#

# Raw filter...

#

# Uncomment the following filter to allow printing of arbitrary files

# without the -oraw option.

#

application/octet-streamapplication/vnd.cups-raw0-

#

# End of "$Id: mime.convs.in 8676 2009-05-22 19:30:50Z mike $".

#

Notate alla fine che abbiamo editato application/octet-stream...per abilitare la stampa di files grezzi

lo stesso faremo con /etc/cupsd/mime.types

#

# "$Id: mime.types 6649 2007-07-11 21:46:42Z mike $"

#

# MIME types file for the Common UNIX Printing System (CUPS).

#

# DO NOT EDIT THIS FILE, AS IT IS OVERWRITTEN WHEN YOU INSTALL NEW

# VERSIONS OF CUPS. Instead, create a "local.types" file that

# reflects your local configuration changes.

#

# Copyright 2007 by Apple Inc.

# Copyright 1997-2007 by Easy Software Products.

#

# These coded instructions, statements, and computer programs are the

# property of Apple Inc. and are protected by Federal copyright

# law. Distribution and use rights are outlined in the file "LICENSE.txt"

# which should have been included with this file. If this file is

# file is missing or damaged, see the license at "http://www.cups.org/".

#

########################################################################

#

# Format of Lines:

#

# super/type rules

#

# "rules" can be any combination of:

#

# ( expr )Parenthesis for expression grouping

# +Logical AND

# , or whitespaceLogical OR

# !Logical NOT

# match("pattern")Pattern match on filename

# extensionPattern match on "*.extension"

# ascii(offset,length)True if bytes are valid printable ASCII

#(CR, NL, TAB, BS, 32-126)

# printable(offset,length)True if bytes are printable 8-bit chars

#(CR, NL, TAB, BS, 32-126, 128-254)

# string(offset,"string")True if bytes are identical to string

# istring(offset,"string")True if bytes are identical to

# case-insensitive string

# char(offset,value)True if byte is identical

# short(offset,value)True if 16-bit integer is identical

# int(offset,value)True if 32-bit integer is identical

# locale("string") True if current locale matches string

# contains(offset,range,"string")True if the range contains the string

#

# General Notes:

#

# MIME type names are case-insensitive. Internally they are converted

# to lowercase. Multiple occurrences of a type will cause the provided

# rules to be appended to the existing definition. Type names are sorted

# in ascending order, so if two types use the same rules to resolve a type

# (e.g. doc extension for two types), the returned type will be the first

# type in the sorted list.

#

# The "printable" rule differs from the "ascii" rule in that it also

# accepts 8-bit characters in the range 128-255.

#

# String constants must be surrounded by "" if they contain whitespace.

# To insert binary data into a string, use the <hex> notation.

#

########################################################################

#

# Application-generated files...

#

#application/msworddoc string(0,<D0CF11E0A1B11AE1>)

application/pdfpdf string(0,%PDF)

application/postscriptai eps ps string(0,%!) string(0,<04>%!) \

contains(0,128,<1B>%-12345X) + \

(contains(0,4096,"LANGUAGE=POSTSCRIPT") \

contains(0,4096,"LANGUAGE = Postscript") \

contains(0,4096,"LANGUAGE = PostScript") \

contains(0,4096,"LANGUAGE = POSTSCRIPT") \

(contains(0,4096,<0a>%!) + \

!contains(0,4096,"ENTER LANGUAGE")))

application/vnd.hp-HPGLhpgl \

string(0,<1B>E<1B>%0B) \

string(0,<1B>%-1B) string(0,<201B>)\

string(0,BP;) string(0,IN;) string(0,DF;) \

string(0,BPINPS;) \

(contains(0,128,<1B>%-12345X) + \

(contains(0,4096,"LANGUAGE=HPGL") \

contains(0,4096,"LANGUAGE = HPGL")))

########################################################################

#

# Image files...

#

image/gifgif string(0,GIF87a) string(0,GIF89a)

image/pngpng string(0,<89>PNG)

image/jpegjpeg jpg jpe string(0,<FFD8FF>) &&\

(char(3,0xe0) char(3,0xe1) char(3,0xe2) char(3,0xe3)\

char(3,0xe4) char(3,0xe5) char(3,0xe6) char(3,0xe7)\

char(3,0xe8) char(3,0xe9) char(3,0xea) char(3,0xeb)\

char(3,0xec) char(3,0xed) char(3,0xee) char(3,0xef))

image/tifftiff tif string(0,MM<002A>) string(0,II<2A00>)

image/x-photocdpcd string(2048,PCD_IPI)

image/x-portable-anymappnm

image/x-portable-bitmappbm string(0,P1) string(0,P4)

image/x-portable-graymappgm string(0,P2) string(0,P5)

image/x-portable-pixmapppm string(0,P3) string(0,P6)

image/x-sgi-rgbrgb sgi bw icon short(0,474)

image/x-xbitmapxbm

image/x-xpixmapxpm ascii(0,1024) + string(3,"XPM")

#image/x-xwindowdumpxwd string(4,<00000007>)

image/x-sun-rasterras string(0,<59a66a95>)

#image/fpxfpx

image/x-aliaspix short(8,8) short(8,24)

image/x-bitmapbmp string(0,BM) && !printable(2,14)

image/x-iconico

########################################################################

#

# Text files...

#

application/x-cshellcsh printable(0,1024) + string(0,#!) +\

(contains(2,80,/csh) contains(2,80,/tcsh))

application/x-perlpl printable(0,1024) + string(0,#!) +\

contains(2,80,/perl)

application/x-shellsh printable(0,1024) + string(0,#!) +\

(contains(2,80,/bash) contains(2,80,/ksh)\

contains(2,80,/sh) contains(2,80,/zsh))

application/x-csourcec cxx cpp cc C h hpp \

printable(0,1024) + \

(string(0,/*) string(0,//)

string(0,#include) contains(0,1024,<0a>#include) \

string(0,#define) contains(0,1024,<0a>#define))

text/htmlhtml htm printable(0,1024) +\

(istring(0,"<HTML>") istring(0,"<!DOCTYPE"))

text/plaintxt printable(0,1024)

text/csscss

########################################################################

#

# RSS feed type...

#

application/rss+xmlrss

########################################################################

#

# CUPS-specific types...

#

application/vnd.cups-commandstring(0,'#CUPS-COMMAND')

application/vnd.cups-formstring(0,"<CUPSFORM>")

application/vnd.cups-pdf

application/vnd.cups-postscript

application/vnd.cups-ppdppd string(0,"*PPD-Adobe:")

application/vnd.cups-rasterstring(0,"RaSt") string(0,"tSaR")

application/vnd.cups-raw(string(0,<1B>E) + !string(2,<1B>%0B)) \

string(0,<1B>@) \

(contains(0,128,<1B>%-12345X) + \

(contains(0,4096,"LANGUAGE=PCL") \

contains(0,4096,"LANGUAGE = PCL")))

########################################################################

#

# Raw print file support...

#

# Comment the following type to prevent raw file printing.

#

application/octet-stream

#

# End of "$Id: mime.types 6649 2007-07-11 21:46:42Z mike $".

#

ora editiamo cupsd.conf che adatteremo per la nostra rete casalinga

#

# "$Id: cupsd.conf.in 7199 2008-01-08 00:16:30Z mike $"

#

# Sample configuration file for the Common UNIX Printing System (CUPS)

# scheduler. See "man cupsd.conf" for a complete description of this

# file.

#

# Log general information in error_log - change "info" to "debug" for

# troubleshooting...

LogLevel info

# Administrator user group...

SystemGroup sys root

# Only listen for connections from the local machine.

Listen 127.0.0.1:631

Listen 192.168.0.2:631

Listen /var/run/cups/cups.sock

# Show shared printers on the local network.

Browsing On

BrowseOrder allow,deny

BrowseAllow all

# Default authentication type, when authentication is required...

DefaultAuthType Basic

# Restrict access to the server...

<Location />

Order Deny,Allow

Deny From All

Allow From 127.0.0.1

Allow From 192.168.0.*

</Location>

# Restrict access to the admin pages...

<Location /admin>

Encryption Required

Order allow,deny

</Location>

# Restrict access to configuration files...

<Location /admin/conf>

AuthType Default

Require user @SYSTEM

Order allow,deny

</Location>

# Set the default printer/job policies...

<Policy default>

# Job-related operations must be done by the owner or an administrator...

<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>

Require user @OWNER @SYSTEM

Order deny,allow

</Limit>

# All administration operations require an administrator to authenticate...

<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>

AuthType Default

Require user @SYSTEM

Order deny,allow

</Limit>

# All printer operations require a printer operator to authenticate...

<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>

AuthType Default

Require user @SYSTEM

Order deny,allow

</Limit>

# Only the owner or an administrator can cancel or authenticate a job...

<Limit Cancel-Job CUPS-Authenticate-Job>

Require user @OWNER @SYSTEM

Order deny,allow

</Limit>

<Limit All>

Order deny,allow

</Limit>

</Policy>

#

# End of "$Id: cupsd.conf.in 7199 2008-01-08 00:16:30Z mike $".

#

Notare le righe

Listen 127.0.0.1:631

Listen 192.168.0.2:631

Listen /var/run/cups/cups.sock

e

Allow From 127.0.0.1

Allow From 192.168.0.*

che aprono l'accesso ai clienti della nostra rete(192.168.0.*)

Riavviamo cupsd

# /etc/rc.d/rc.cups restart

Adesso supponiamo di avere una stampante sul server che vogliamo

condividere,i client windows useranno samba

(abbiamo impostato samba con la condivisione delle stampanti) ,

quelli linux cups aggiungiamo la stampante con il classico procedimento

usando http://localhost:631 la stampante nell'esempio è installata sul server ed è chiamata

EpsonS20.

Adesso per raggiungerla e stamparci dal client Linux avviate cups,usando sempre

http://localhost:631 ma questa volta sceglieremo come Dispositivo Internet Printing Protocol(HTTP)

e come indirizzo daremo http://192.168.0.2:631/printers/EpsonS20 procedete poi come quando installate una

stampante in locale.

Ovviamente "EpsonS20" è il nome della stampante di esempio,voi userete un nome a piacere,l'importante è che siano

uguali nel server e nel client.

Col client Windows è ancora più semplice,andate su Risorse di rete,autenticatevi sul server linux cliccandoci sopra e scegliete

tra le condivisioni la stampante condivisa.

Su alcune versioni di Windows è probabile che non vengano trovati i drivers,allora andate sul sito del produttore

della stampante,installate i drivers e ripetete la procedura.

Su Windows 7 e Windows 2008R2 è consigliato usare anzichè la procedura classica(stampante condivisa da Samba) la installazione stampante di rete, eseguite la stessa procedura che avete fatto col client Linux.

Ultimo aggiornamento: 2011-05-21

Torna all'indice