GentooIntroduction to Samba Part 2.docx
《GentooIntroduction to Samba Part 2.docx》由会员分享,可在线阅读,更多相关《GentooIntroduction to Samba Part 2.docx(11页珍藏版)》请在冰点文库上搜索。
![GentooIntroduction to Samba Part 2.docx](https://file1.bingdoc.com/fileroot1/2023-6/6/c776597c-253f-479a-b5e8-188aac3eedfe/c776597c-253f-479a-b5e8-188aac3eedfe1.gif)
GentooIntroductiontoSambaPart2
Disclaimer:
TheoriginalversionofthisarticlewasfirstpublishedonIBMdeveloperWorks,andispropertyofWesttechInformationServices.Thisdocumentisanupdatedversionoftheoriginalarticle,andcontainsvariousimprovementsmadebytheGentooLinuxDocumentationteam.
Thisdocumentisnotactivelymaintained.
IntroductiontoSamba,Part2
1. Compiling,installing,andconfiguringSambaforyourenvironment
DownloadingSamba
OK,it'stimetodownloadSamba2.0.7orgreaterfromtheSamba.orgWebsite(seeResourceslaterinthisarticle).
Note:
WhileI'llbecompilingSambafromscratch,youmaychoosetoinstallSambafromabinarypackage(suchasRPMthatcamewithyourLinuxdistribution).ThisisperfectlyOK.But,asImentionedinmylastarticle,ifyoudothis,yourfilelocationsmaybeslightlydifferentthanwhatIrefertohere.
Afteryou'vedownloadedSamba2.0.7orgreater,it'stimetodecompressittoadirectorylocationofyourchoice.Fromthecommandprompt,type:
CodeListing 1.1:
Unpackingthesourcefiles
$tar-xzvfsamba-2.0.7.tar.gz
Asamba-2.0.7directorywillbecreated.cdintoit,andwe'lltakealookaround.First,noticethedocsdirectory.Insideityou'llseeanotherdirectorycalledtextdocs.texdocscontainsawholebunchofSambadocumentation.OneofthemostimportantfilesinthetextdocsdirectoryiscalledDIAGNOSIS.txt.Itwalksyouthroughastep-by-stepprocessofdiagnosingproblemsyoumayhavewithproperSambaoperation.We'llbecoveringsome,butnotall,ofthediagnosisproceduresmentionedinthisfile.
CompilingandinstallingSamba
You'llalsonoticethesourcesdirectoryinthemainsamba-2.0.7directory.Insidesourcesyou'llfindawelldesignedconfigurescriptdesignedtosetupallthemakefilesproperly.Aswithanyotherconfigurescript,togetalistoftheconfigurationoptions,type:
CodeListing 1.2:
Investigatingoptions
$./configure--help
Youwillprobablywanttopipetheoutputtomoresothatyoucanviewalltheoptions:
CodeListing 1.3:
Evenmoreoptions
$./configure--help|more
Notethedirectoryandfilenameoptions.Noticewhereeverythinggetsinstalled,andthatthedefaultinstallpathis/usr/local/samba.Youwillprobablywanttochangethisto/usr/localbypassingthe--prefix=/usr/localoptionwhenyouconfigureSamba.Forthisexample,I'mgoingtousethefollowingpathsettings:
CodeListing 1.4:
Configuringthedirectoryoptions
$./configure--prefix=/usr/local--localstatedir=/var/log--sysconfdir=/etc
TheaboveconfigurationoptionswillcauseSamba'sdefaulttreetobein/usr/local,withtheexceptionoftheconfigurationfiles.Sambawillexpecttofindthesein/etcandlogfiles,whichwillendupin/var/log.Ifyouomitthoseconfigureoptions,you'llfindeverythinginthe/usr/local/sambadirectorytree(/usr/local/samba/var,/usr/local/samba/etc,etc.).
It'snowtimetostartthecompilation.Afterrunningconfigure,type:
CodeListing 1.5:
CompilingSamba
$make
Aftercompilationcompletes,typethefollowingasroottoinstallthesoftware:
CodeListing 1.6:
InstallingSamba
#makeinstall
Configuringtheserver
Forthemostpart,configuringSambabeginsandendswiththesmb.conffile.ThisisSamba'smainconfigurationfile.Ithasmanydifferentconfigurationoptions.Toavoidconfusion,we'regoingtostartonlywiththoseoptionsessentialtotheproperoperationofSamba.First,you'llneedtofindoutwheresmb.confshouldbe.IfyouusedtheconfigurationoptionsIspecifiedabove,youshouldplacesmb.confin/etc.Ifyouusedthedefaultpaths,Sambawilllookforitin/usr/local/samba/etc.Togetstarted,cdtotheappropriatedirectory,fireupyourfavoritetexteditor,andtypeinthefollowinglines.I'llinterspersecommentaryalongthewaytoprovideyouwithagoodunderstandingofwhateachoptiondoes.Addtheselinestoyoursmb.conffile:
CodeListing 1.7:
smb.conf
[global]
workgroup=YOURWORKGROUP
security=user
encryptpasswords=yes
guestaccount=guest
ThefirstlinetellsSambathatweareplacingoptionsinthe"global"section.Therearemanyoptionsthatareintendedtobedefinedonlyinthissection.TheseoptionscontroltheglobalbehaviorofSamba.
ThesecondlinetellsSambathenameoftheWindowsworkgroupthatSambawillcreate.ReplaceYOURWORKGROUPwithanappropriatenameforyourworkgroup.
Onthethirdline,wetellSambatoruninuser-levelsecuritymode.ThisoptionwillcauseSambatotellallconnectingWindowsclientsthattheyneedtoprovideavalidusername/passwordcombinationtogainaccesstoanynetworkresource.Thisisdefinitelyagoodthing.User-levelsecurityisSamba'smostoftenusedsecuritylevelbecauseit'sanexcellentmatchforthemajorityoffilesharingsituations.However,thereareothersecuritylevelsavailable.OnehandymodetellsSambatoauthenticateallusersagainstthesecuritydatabaseofanexistingWindowsNTor2000Server.Wewon'tbecoveringthatparticularmodeinthisarticle.Ifyouwantmoreinformationaboutit,takealookatthe"security"optioninthesmb.confmainpage.
Now,ontothefourthline.HerewetellSambatoexchangepasswordswithSambainencryptedmode.YouwillalwayswanttorunSambainencryptedmode,unlessallyourclientmachinesareextremelyancient(likeWindowsforWorkgroups-eramachines).EnablingencryptedpasswordsdoescauseSambatoneeditsownpasswordfile,inadditiontothestandardUnixpassworddatabase.Ifyouarethinkingthatitmaybenicetoturnencryptedpasswordsoff,sothatyoucanavoidhavingtomaintaintwopasswordfiles,don'tdoit!
TurningencryptedpasswordsoffwillcausesharingproblemswithevenmoderatelyoldversionsofWindowsNT4.0inadditiontoWindows2000.Ifyoureallywanttoavoidmaintainingtwoseparatedatabases,Sambaprovidesseveralwaystosynchronizebothdatabases,whichisabetterapproach.
ThenextlinespecifiesavalidUnixuseraccountthatwillbeusedforguestaccess.Whilepeopleoftenuse"guestaccount=nobody",it'srecommendedthatyouaddaliteral"guest"usertoyoursystemifonedoesn'texistalready.Thenew"guest"accountdoesnotneedapasswordsetanddoesnotneedtobeabletologininteractively.(It'sfineifyoudochoosetoconfigureguestwithapasswordandavaliddefaultshell.)
Nowwe'rereadytoaddWINSsupportoptionstosmb.conf.You'llwanttoaddoneofthefollowingtwolinestotheglobalsection:
CodeListing 1.8:
WINSsupport
winssupport=yes
OR
CodeListing 1.9:
WINSserverIPaddress
winsserver=IPaddressofWINSserver
IfyoualreadyhaveaWINSserveronyourcurrentsubnet(aWindowsNTServerrunningWINS,forexample),you'llwanttousethesecondoptionandspecifythenameoftheWINSserverontherightsideoftheequalssign.Samba'sinternalWINSserviceswillthenbedisabled,anditwillusetheWINSserveryouspecify.
Ifyoudon'thaveaWINSserverrunningonyoursubnet,oryou'resettingSambaupathomeandyoudon'tknowexactlywhataWINSserveris,you'llwanttousethefirstoption.ThiswilltellSambatobecomeaWINSserverforyourLAN.
YoumaybewonderingwhatWINSdoes.Basically,youcanthinkofWINSasalocaldynamicDNSdatabase.WhenSambaisrunningasaWINSserver,everyWindows-compatiblemachineonthesamesubnetwillregisteritsIPaddressandNetBIOSname(a.k.a."computername")withSamba.ThisenablesWindowsmachinestouseSamba'sWINSdatabasetorequestanIPaddressforaparticularNetBIOSname.WINSisakeycomponentofnetworkbrowsing,whichiswhatyouaredoingwhenyoupokearoundinsidetheNetworkNeighborhoodonaWindowsmachine.
Nowwe'rereadytoaddseveralmoreoptionstotheglobalsection:
CodeListing 1.10:
Networkbrowsingsetup
localmaster=yes
oslevel=99
domainmaster=yes
preferredmaster=yes
Nowforanexplanation.Alltheseoptionsarerelatedtonetworkbrowsing.I'vealreadymentionedthatWINSisakeycomponentofnetworkbrowsing,butthere'sanotherelementrequiredforbrowsingtoworkproperly.Alocalmasterbrowsermustexist.Soundstrange?
Somefurtherexplanationisrequired.
Forbrowsingtoworkproperly,theremustbesomecentrallocationthatkeepstrackofwhatmachinesandworkgroupsexistonthelocalsubnet.Thisparticularlistiscalledthebrowselist.Thebrowselistisusedtoconstructthelistofworkgroups,domains,andmachinesyouseewhenyoufirstclickontheNetworkNeighborhood.AnymodernWindowsmachinecanbecomethelocalmasterbrowser.Ideally,we'dlikeSambatobethelocalmasterbrowseronthenetwork.
Howisthisaccomplished?
Basically,severalbeefyWindows-compatiblemachinesonyoursubnetwillregularlydukeitoutbyflingingpacketsbackandforthacrossyourLANinanattempttodeterminewhowillbecomethelocalmasterbrowser.Thisprocessiscalleda"browserelection."
Note:
Beagoodsport.Pleasedon'tuseSamba'sabilitytobeatWindowsinallbrowserelectionsasanexcusetoteaseMicrosoftadministratorsinyourorganization.Remember,it'simportanttobeagoodwinner.
Intheendthe"winner"ofthisbroadcastpacketwargetstobecomethelocalmasterbrowser.WecancauseSambatowinthebattlebyusingtheoslevel=99option,whichcausesittobeateveryothermachineontheLAN.ThishappensbecauseeveryversionofWindows(fromWindows95toNTto2000)hasahard-codedOSlevelthatwasintendedtocausethemostadvancedversionofWindowstobecomethelocalmasterbrowser(laterversionsofWindowshaveabiggernumber).SettingSambato99willcauseittobeatallMicrosoftproducts,allowingittobecomethelocalmaster