下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
修改linux端⼝范围ip_local_port_rangetags:ip_local_port_range端⼝范围sysctlLinux中有限定端⼝的使⽤范围,如果我要为我的程序预留某些端⼝,那么我需要控制这个端⼝范围,本⽂主要描述如何去修改端⼝范围。12/proc/sys/net/ipv4/ip_local_port_range的原⽂解释:The/proc/sys/net/ipv4/ip_local_port_rangedefinesthelocalportrangethatisusedbyTCPandUDPtraffictochoosethelocalport.Youwillseeintheparametersofthisfiletwonumbers:ThefirstnumberisthefirstlocalportallowedforTCPandUDPtrafficontheserver,thesecondisthelastlocalportnumber.Forhigh-usagesystemsyoumaychangeitsdefaultparametersto32768-61000-first-last./proc/sys/net/ipv4/ip_local_port_range定义了本地tcp/udp的端⼝范围。可以理解为系统中的程序会选择这个范围内的端⼝来连接到⽬的端⼝(⽬的端⼝当然是⽤户指定的)。12[root@localhost~]#cat/proc/sys/net/ipv4/ip_local_port_range3276861000可以看到,现在定义的范围是32768-61000.如果想修改这个范围,可以使⽤sysctl⼯具,sysctl的配置⽂件位于/etc/sysctl.conf。先看⼀下man中的描述12345678910111213141516171819202122232425262728293031323334[root@kedacommcu]#mansysctlSYSCTL(8)SYSCTL(8)NAMEsysctl-configurekernelparametersatruntimeSYNOPSISsysctl[-n][-e]variable...SYSCTL(8)SYSCTL(8)NAMEsysctl-configurekernelparametersatruntimeSYNOPSISsysctl[-n][-e]variable...sysctl[-n][-e][-q]-wvariable=value...sysctl[-n][-e][-q]-p<filename>sysctl[-n][-e]-asysctl[-n][-e]-ADESCRIPTIONsysctlisusedtomodifykernelparametersatruntime.Theparametersavailablearethoselistedunder/proc/sys/.Procfsisrequiredforsysctl(8)supportinLinux.Youcanusesysctl(8)tobothreadandwritesysctldata.PARAMETERSvariableThenameofakeytoreadfrom.Anexampleiskernel.ostype.The??separatorisalsoacceptedinplaceofa??variable=valueTosetakey,usetheformvariable=value,wherevariableisthekeyandvalueisthevaluetosetitto.Ifthevaluecontainsquotesorcharacterswhichareparsedbytheshell,youmayneedtoenclosethevalueindoublequotes.Thisrequiresthe-wparametertouse.-nUsethisoptiontodisableprintingofthekeynamewhenprintingvalues.-eUsethisoptiontoignoreerrorsaboutunknownkeys.34353637383940414243444546474849505152535455565758596061printthenames.Itmaybeusefulwithshellsthathaveprogrammablecompletion.-NUsethisoptiontoonly-qUsethisoptiontonotdisplaythevaluessettostdout.-wUsethisoptionwhenyouwanttochangeasysctlsetting.-pLoadinsysctlsettingsfromthefilespecifiedor/etc/sysctl.confifnonegiven.Specifying-asfilenamemeansreadingdatafromstandardinput.-aDisplayallvaluescurrentlyavailable.-ASameas-aEXAMPLES/sbin/sysctl-a/sbin/sysctl-nkernel.hostname/sbin/sysctl-wkernel.domainname=""/sbin/sysctl-p/etc/sysctl.confNOTESPleasenotethatmodulesloadedaftersysctlisrunmayoverridethesettings(example:sunrpc.*settingsareoverriddenwhenthesunrpcmoduleisloaded).Thismaycausesomeconfusionduringbootwhenthesettingsinsysctl.confmaybeoverriden.Topreventsuchasituation,sysctlmustberunaftertheparticularmoduleisloaded(e.g.,from/etc/rc.d/rc.localorbyusingtheinstalldirectiveinmodprobe.conf)配置⽂件中也许没有定于范围,那么可以在⽂件中加上,见最后的#test段:123456789101112131415161718192021222324252627282930313233[root@localhost~]#vim/etc/sysctl.conf#KernelsysctlconfigurationfileforRedHatLinux##Forbinaryvalues,0isdisabled,1isenabled.Seesysctl(8)and#sysctl.conf(5)formoredetails.#ControlsIPpacketforwardingnet.ipv4.ip_forward=0#Controlssourcerouteverificationnet.ipv4.conf.default.rp_filter=1#Donotacceptsourceroutingnet.ipv4.conf.default.accept_source_route=0#ControlstheSystemRequestdebuggingfunctionalityofthekernelkernel.sysrq=0#ControlswhethercoredumpswillappendthePIDtothecorefilename#Usefulfordebuggingmulti-threadedapplicationskernel.core_uses_pid=1#ControlstheuseofTCPsyncookiesnet.ipv4.tcp_syncookies=1#Controlsthemaximumsizeofamessage,inbyteskernel.msgmnb=65536#Controlsthedefaultmaxmimumsizeofamesagequeuekernel.msgmax=65536#Controlsthemaximumsharedsegmentsize,inbyteskernel.shmmax=6871947673633343536373839#Controlsthemaximumnumberofsharedmemorysegments,inpageskernel.shmall=4294967296#testnet.ipv4.ip_local_port_range=3276859000修改后,可以使⽤以下命令重新加载123456789101112[root@localhost~]#sysctl-p/etc/sysctl.confnet.ipv4.ip_forward=0net.ipv4.conf.default.rp_filter=1net.ipv4.conf.default.accept_source_route=0kernel.sysrq=0kernel.core_uses_pid=1net.ipv4.tcp_sy
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 循环流化床锅炉控制氮氧化物的措施
- 沪科版九年级全册物理第十六章 实践:设计安全用电科普活动 同步精讲精炼学案
- 2026新教材人教PEP版五年级上册英语Unit 4 Healthy habits 教案
- 2026年尾矿处理工专项题库(附答案与解释)
- 江西省初一下学期期末语文梳理要点解析
- 统编语文四年级上册期中检测试(附答案)
- 皮肤与性病学(中级338)基础知识卫生专业技术资格考试巩固重点解析(2026年)
- 【新教材】赣美版(2024)一年级上册美术第七单元 20 庆团圆 教案
- 期末模拟测试卷四(试卷)2025-2026学年二年级数学下册人教版(含答案)
- 土建质量员与基础知识
- 人教版小学一年级数学下册各单元练习题
- 安徽省合肥一中、安庆一中等六校2026届高一下生物期末复习检测试题含解析
- 部队内部物业管理制度
- 2025年录音师考试《同期录音》技巧
- 2026高压电工证资格考试核心题库(答案及解析)
- 2026年自然资源监测的遥感技术
- (新版)保卫管理员(三级)职业技能等级认定考试题库(答案及解析)
- 塑料管材生产安全制度
- 2025年1月浙江首考高考英语试卷真题完整版(含答案+听力原文)
- 顾客满意度评价方法手册(标准版)
- 镀膜安全操作培训总结课件
评论
0/150
提交评论