ZeroTierOne A Smart Ethernet Switch for Earth开源项目

我要开发同款
匿名用户2021年11月30日
32阅读
开发技术C/C++
所属分类程序开发、网络工具包
授权协议View license

作品详情

ZeroTier-GlobalAreaNetworking

Thisdocumentiswrittenforasoftwaredeveloperaudience.ForinformationonusingZeroTier,seethe:Website,DocumentationSite,andDiscussionForum

ZeroTierisasmartprogrammableEthernetswitchforplanetEarth.Itallowsallnetworkeddevices,VMs,containers,andapplicationstocommunicateasiftheyallresideinthesamephysicaldatacenterorcloudregion.

Thisisaccomplishedbycombiningacryptographicallyaddressedandsecurepeertopeernetwork(termedVL1)withanEthernetemulationlayersomewhatsimilartoVXLAN(termedVL2).OurVL2EthernetvirtualizationlayerincludesadvancedenterpriseSDNfeatureslikefinegrainedaccesscontrolrulesfornetworkmicro-segmentationandsecuritymonitoring.

AllZeroTiertrafficisencryptedend-to-endusingsecretkeysthatonlyyoucontrol.Mosttrafficflowspeertopeer,thoughweofferfree(butslow)relayingforuserswhocannotestablishpeertopeerconnections.

ThegoalsanddesignprinciplesofZeroTierareinspiredbyamongotherthingstheoriginalGoogleBeyondCorppaperandtheJerichoForumwithitsnotionof"deperimeterization."

VisitZeroTier'ssiteformoreinformationandpre-builtbinarypackages.AppsforAndroidandiOSareavailableforfreeintheGooglePlayandAppleappstores.

ZeroTierislicensedundertheBSLversion1.1.SeeLICENSE.txtandtheZeroTierpricingpagefordetails.ZeroTierisfreetouseinternallyinbusinessesandacademicinstitutionsandfornon-commercialpurposes.Certaintypesofcommercialusesuchasbuildingclosed-sourceappsanddevicesbasedonZeroTierorofferingZeroTiernetworkcontrollersandnetworkmanagementasaSaaSservicerequireacommerciallicense.

AsmallamountofthirdpartycodeisalsoincludedinZeroTierandisnotsubjecttoourBSLlicense.SeeAUTHORS.mdforalistofthirdpartycode,whereitisincluded,andthelicensesthatapplytoit.AllofthethirdpartycodeinZeroTierisliberallylicensed(MIT,BSD,Apache,publicdomain,etc.).

GettingStarted

EverythingintheZeroTierworldiscontrolledbytwotypesofidentifier:40-bit/10-digitZeroTieraddressesand64-bit/16-digitnetworkIDs.Theseidentifiersareeasilydistinguishedbytheirlength.AZeroTieraddressidentifiesanodeor"device"(laptop,phone,server,VM,app,etc.)whileanetworkIDidentifiesavirtualEthernetnetworkthatcanbejoinedbydevices.

ZeroTieraddressescanbethoughtofasportnumbersonanenormousplanet-wideenterpriseEthernetsmartswitchsupportingVLANs.NetworkIDsareVLANIDstowhichtheseportsmaybeassigned.AsingleportcanbeassignedtomorethanoneVLAN.

AZeroTieraddresslookslike8056c2e21candanetworkIDlookslike8056c2e21c000001.NetworkIDsarecomposedoftheZeroTieraddressofthatnetwork'sprimarycontrollerandanarbitrary24-bitIDthatidentifiesthenetworkonthiscontroller.NetworkcontrollersareroughlyanalogoustoSDNcontrollersinSDNprotocolslikeOpenFlow,thoughaswiththeanalogybetweenVXLANandVL2thisshouldnotbereadtoimplythattheprotocolsordesignarethesame.YoucanuseourconvenientandinexpensiveSaaShostedcontrollersatmy.zerotier.comorrunyourowncontrollerifyoudon'tmindmessingaroundwithJSONconfigurationfilesorwritingscriptstodoso.

ProjectLayout

ThebasepathcontainstheZeroTierOneservicemainentrypoint(one.cpp),selftestcode,makefiles,etc.

artwork/:icons,logos,etc.attic/:oldstuffandexperimentalcodethatwewanttokeeparoundforreference.controller/:thereferencenetworkcontrollerimplementation,whichisbuiltandincludedbydefaultondesktopandserverbuildtargets.debian/:filesforbuildingDebianpackagesonLinux.doc/:manualpagesandotherdocumentation.ext/:thirdpartylibraries,binariesthatweshipforconvenienceonsomeplatforms(MacandWindows),andinstallationsupportfiles.include/:includefilesfortheZeroTiercore.java/:aJNIwrapperusedwithourAndroidmobileapp.(ThewholeAndroidappisnotopensourcebutmaybemadesointhefuture.)macui/:aMacintoshmenu-barappforcontrollingZeroTierOne,writteninObjectiveC.node/:theZeroTiervirtualEthernetswitchcore,whichisdesignedtobeentirelyseparatefromtherestofthecodeandabletobebuiltasastand-aloneOS-independentlibrary.Notetodevelopers:donotuseC++11featuresinhere,sincewewantthistobuildonoldembeddedplatformsthatlackC++11support.C++11canbeusedelsewhere.osdep/:codetosupportandintegratewithOSes,includingplatform-specificstuffonlybuiltforcertaintargets.rule-compiler/:JavaScriptruleslanguagecompilerfordefiningnetwork-levelrules.service/:theZeroTierOneservice,whichwrapstheZeroTiercoreandprovidesVPN-likeconnectivitytovirtualnetworksfordesktops,laptops,servers,VMs,andcontainers.windows/:VisualStudiosolutionfiles,Windowsservicecode,andtheWindowstaskbarappUI.BuildandPlatformNotes

TobuildonMacandLinuxjusttypemake.OnFreeBSDandOpenBSDgmake(GNUmake)isrequiredandcanbeinstalledfrompackagesorports.ForWindowsthereisaVisualStudiosolutioninwindows/.

MacXcodecommandlinetoolsforOSX10.8ornewerarerequired.LinuxTheminimumcompilerversionsrequiredareGCC/G++4.9.3orCLANG/CLANG++3.4.2.(InstallclangonCentOS7asG++istooold.)Linuxmakefilesautomaticallydetectandpreferclang/clang++ifpresentasitproducessmallerandslightlyfasterbinariesinmostcases.YoucanoverridebysupplyingCCandCXXvariablesonthemakecommandline.WindowsWindows7ornewerissupported.ThismayworkonVistabutisn'tofficiallysupportedthere.ItwillnotworkonWindowsXP.WebuildwithVisualStudio2017.Olderversionsmaynotwork.ClangorMinGWwillalsoprobablyworkbutmayrequiresomemakefilehacking.FreeBSDGNUmakeisrequired.Typegmaketobuild.OpenBSDThereisalimitoffournetworkmembershipsonOpenBSDasthereareonlyfourtapdevices(/dev/tap0through/dev/tap3).GNUmakeisrequired.Typegmaketobuild.

Typingmakeselftestwillbuildazerotier-selftestbinarywhichunittestsvariousinternalsandreportsonafewaspectsofthebuildenvironment.It'sagoodideatotrythisonnovelplatformsorarchitectures.

Running

Runningzerotier-onewith-hoptionwillshowhelp.

OnLinuxandBSD,ifyoubuiltfromsource,youcanstarttheservicewith:

sudo./zerotier-one-d

Onmostdistributions,macOS,andWindows,theinstallerwillstarttheserviceandsetituptostartonboot.

Ahomefolderforyoursystemwillautomaticallybecreated.

TheserviceiscontrolledviatheJSONAPI,whichbydefaultisavailableat127.0.0.1port9993.Weincludeazerotier-clicommandlineutilitytomakeAPIcallsforstandardthingslikejoiningandleavingnetworks.Theauthtoken.secretfileinthehomefoldercontainsthesecrettokenforaccessingthisAPI.Seeservice/README.mdforAPIdocumentation.

Here'swherehomefolderslive(bydefault)oneachOS:

Linux:/var/lib/zerotier-oneFreeBSD/OpenBSD:/var/db/zerotier-oneMac:/Library/ApplicationSupport/ZeroTier/OneWindows:\ProgramData\ZeroTier\One(That'sforWindows7.Thebase'sharedappdata'foldermightbedifferentondifferentWindowsversions.)BasicTroubleshooting

Formostusers,itjustworks.

Ifyouarerunningalocalsystemfirewall,werecommendaddingarulespermittingzerotier.IfyouinstalledbinariesforWindowsthisshouldbedoneautomatically.Otherplatformsmightrequiremanualeditingoflocalfirewallrulesdependingonyourconfiguration.

Seethedocumentationsiteformoreinformation.

TheMacfirewallcanbefoundunder"Security"inSystemPreferences.Linuxhasavarietyoffirewallconfigurationsystemsandtools.

OnCentOScheck/etc/sysconfig/iptablesforIPTablesrules.Forotherdistributionsconsultyourdistribution'sdocumentation.You'llalsohavetochecktheUIsordocumentationforcommercialthirdpartyfirewallapplicationslikeLittleSnitch(Mac),McAfeeFirewallEnterprise(Windows),etc.ifyouarerunninganyofthose.Somecorporateenvironmentsmighthavecentrallymanagedfirewallsoftware,soyoumightalsohavetocontactIT.

ZeroTierOnepeerswillautomaticallylocateeachotherandcommunicatedirectlyoveralocalwiredLANifUDPport9993inboundisopen.Ifthatportisfiltered,theywon'tbeabletoseeeachothers'LANannouncementpackets.Ifyou'reexperiencingpoorperformancebetweendevicesonthesamephysicalnetwork,checktheirfirewallsettings.WithoutLANauto-locationpeersmustattempt"loopback"NATtraversal,whichsometimesfailsandinanycaserequiresthateverypackettraverseyourexternalroutertwice.

Usersbehindcertaintypesoffirewallsand"symmetric"NATdevicesmaynotableabletoconnecttoexternalpeersdirectlyatall.ZeroTierhaslimitedsupportforportpredictionandwillattempttotraversesymmetricNATs,butthisdoesn'talwayswork.IfP2Pconnectivityfailsyou'llbebouncingUDPpacketsoffourrelayserversresultinginslowerperformance.SomeNATrouter(s)haveaconfigurableNATmode,andsettingthisto"fullcone"willeliminatethisproblem.IfyoudothisyoumayalsoseeamagicalimprovementforthingslikeVoIPphones,Skype,BitTorrent,WebRTC,certaingames,etc.,sincealloftheseuseNATtraversaltechniquessimilartoours.

IfafirewallbetweenyouandtheInternetblocksZeroTier'sUDPtraffic,youwillfallbacktolast-resortTCPtunnelingtorootserversoverport443(httpsimpersonation).ThiswillworkalmostanywherebutisveryslowcomparedtoUDPordirectpeertopeerconnectivity.

Additionalhelpcanbefoundinourknowledgebase.

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论