ipv4

TIME_WAIT状态全是3306解决办法

╄→尐↘猪︶ㄣ 提交于 2019-12-03 05:45:08
刚吃完晚饭,手机短信一直响个不停,打开一看全是告警信息,立即打开电脑查看,发现很多网页很不稳定 一会能打开,一会打不开 登录服务器查看负载情况,cpu、内存 、磁盘io 负载都不高,查看日志发现nginx有大量的502错误,首先怀疑是nginx调用后端的php程 序出问题了。为了不影响业务,我先尝试了重启程序,重启之后刷新了页面发现还是时好时坏,php日志和系统日志都没报什么错误, 就ngxinx日志一直在刷502错误,查看了tcp的链接数,使用netstat -na | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'查看了各个 状态的数量,呵呵。。。。。,感觉不对了,怎么TIME_WAIT状态的怎么有3282个,等等看下到底是什么鬼占用的,发现都是连接mysql 数据库的端口,一定是什么原因导致程序没有正常关闭。占用了大量资源,导致后面的请求一直处于排队超时 90%的time_wait都是连接3306端口 不对啊,之前对内核参数已经做过一次调优,再次确认配置文件,发现没有加超时时间限制, net.ipv4.tcp_fin_timeout = 30 vi /etc/sysctl.conf net.ipv4.tcp_syncookies = 1 #表示开启SYN Cookies。当出现SYN等待队列溢出时

What is the total amount of public IPv4 addresses?

十年热恋 提交于 2019-12-03 05:25:50
问题 Yes, I am needing to know what the total number possible IPs in the public IPv4 space. I'm not sure where to even get a neat list of all the IP address ranges, so could someone point me to a resource to calculate this myself or calculate the total number of IPs for me? Also, by Public IPs I mean not counting reserved or private-range IP addresses.. Only the ones that can be access through the internet. 回答1: According to Reserved IP addresses there are 588,514,304 reserved addresses and since

IPv6 lookup data structure

亡梦爱人 提交于 2019-12-03 05:23:41
问题 A patricia trie is the well-know, recommended data structure for storing IPv4 allocations/assignments and performing lookup. Is this true for IPv6 adddresses too? Just a deeper/taller trie to accommodate the extra 96 bits? Is the trie still patricia, or a different radix trie? 回答1: You can still use Patricia tries with a bigger depth, but the problem is the performance degrades linearly with the trie depth. Designing specialized data structures for IPv6 lookup is an active field. Recent

java.net.NoRouteToHostException: Cannot assign requested address 问题分析

时光怂恿深爱的人放手 提交于 2019-12-03 05:10:14
问题: 错误原因: 由于liunx 分配的客户端连接端口用尽,无法建立socket连接所致,虽然socket正常关闭,但是端口不是立即释放,而是处于 TIME_WAIT 状态,默认等待60s后释放。 查看liunx支持的客户端连接端口范围,也就是 28232 个端口。 cat /proc/sys/net/ipv4/ip_local_port_range 32768 - 61000 解决方法: 1. 调低端口释放后的等待时间,默认为60s,修改为15~30s。 echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout 2. 修改 tcp/ip 协议配置,通过配置 /proc/sys/net/ipv4/tcp_tw_reuse ,默认为0,修改为1,释放 TIME_WAIT 端口给新连接使用。 echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse 3. 修改 ctp/ip 协议配置,快速回收socket资源,默认为0.修改为1。 echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle https://blog.csdn.net/weixin_43757847/article/details/88188091 https://my.oschina.net/shichangcheng/blog

Geolocation with IPv6?

岁酱吖の 提交于 2019-12-03 04:23:07
问题 I'm working on an IP geolocation library that uses the first three octets of an IPv4 address to determine a user's country, city, lat, lon, etc. Works like a charm. But it doesn't handle IPv6 addresses, and I'd like it to do so. Is there any way to transform an IPv6 address to get the equivalent of the first three octets of an IPv4 address, or are they on an entirely different numbering scheme, requiring a completely different ipgeo mapping? 回答1: The typical IPv6 allocation is a /32 (four

INET_NTOA and INET_ATON in Java?

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use Java (with Spring framework) and want to convert between numeric representations of IPv4 addresses (e.g. 2130706433) and their textual counterparts (e.g. 127.0.0.1 ). Often, methods for doing this are supplied in programming languages (they're usually called INET_NTOA and INET_ATON respectively) but I can't find it in Java. Anybody knows what they're called or how to implement them? 回答1: Look at InetAddress in the javadocs. These functions are not directly supported by the Standard API but you can extract both representations using

Converting C++ TCP/IP applications from IPv4 to IPv6. Difficult? Worth the trouble?

自闭症网瘾萝莉.ら 提交于 2019-12-03 02:22:27
问题 Over the years I've developed a small mass of C++ server/client applications for Windows using WinSock (Routers, Web/Mail/FTP Servers, etc... etc...). I’m starting to think more and more of creating an IPv6 version of these applications (While maintaining the original IPv4 version as well, of course). Questions: What pitfalls might I run into? Is the porting/conversion difficult? Is the conversion worth it? For a reference (or for fun), you can sneek a peak of the IPv4 code at the core of my

Force requests to use IPv4 / IPv6

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to force the requests library to use a specific internet protocol version for a get request? Or can this be achieved better with another method in Python? I could but I do not want to use curl … Example to clarify purpose: import requests r = requests.get('https://my-dyn-dns-service.domain/?hostname=my.domain', auth = ('myUserName', 'my-password')) 回答1: This is totally untested and will probably require some tweaks, but combining answers from Using Python “requests” with existing socket connection and how to force python httplib library

ipv4的ip字符串转化为int型

让人想犯罪 __ 提交于 2019-12-03 02:14:54
要求:   将现有一个ipv4的ip字符串(仅包含数字,点,空格), 其中数字和点之间的空格(至多一个)是合法的,比如“12 .3. 4 .62”,其他情况均为非法地址。写一个函数将ipv4地址字符串转化成32位整数。 实现: #include<stdio.h> #include<string.h> int is_digit(char ch) { if(ch>='0' && ch<='9') return 1; return 0; } int ipv4_to_int(char* str, int* part) { int len=0,index=0,i=0; char* ps=str; if(ps == NULL) return -1; len=strlen(ps); if(len<7 || len >21) return -1; if(!is_digit(ps[0]) || !is_digit(ps[len-1]) ) return -1; part[index]=part[index]*10+(int)(ps[0]-'0'); for(i=1;i<len-1;i++){ char ch = ps[i]; if(is_digit(ch)){ part[index]=part[index]*10+(int)(ch-'0'); if(part[index]>255) return

How to support both IPv4 &amp; IPv6 on Java

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: One of our Java program when started, it only listen on IPv6 (8080) e.g. # netstat -ntpl Proto Recv - Q Send - Q Local Address Foreign Address State PID / Program name tcp 0 0 0.0 . 0.0 : 22 0.0 . 0.0 :* LISTEN - tcp6 0 0 ::: 8080 :::* LISTEN - tcp6 0 0 ::: 22 :::* LISTEN - The problem is it is not accessible from outside (except localhost), to solve this, I have this manually add - Djava . net . preferIPv4Stack = true But this make the program is only for IPv4 network. Is it possible to do something like the sshd as above, both