ipv4

Convert IPv6 to IPV4 PHP

非 Y 不嫁゛ 提交于 2020-01-18 00:01:08
问题 I have a list of IPv4 IPs selected from a database which stores the addresses as BINARY(16). Is there any simple way to convert the IPv6 formated address to human readable IPv4 format? This is what the IPv4 address looks like 8ab8:7f70:: 回答1: As Ron Maupin described, the solution is very simple $ipv6 = "8ab8:7f70::"; $ipv4 = hexdec(substr($ipv6, 0, 2)). "." . hexdec(substr($ipv6, 2, 2)). "." . hexdec(substr($ipv6, 5, 2)). "." . hexdec(substr($ipv6, 7, 2)); 来源: https://stackoverflow.com

IPv4分析

女生的网名这么多〃 提交于 2020-01-17 13:50:02
IPv4的头部格式: 1. Version 版本号,默认是4。 2. IHL(Internet Header Length) 就是IPv4头部长度。这个长度的单位是32bit,一般是5,那么头部的长度就是5x32bit=160bit。 3. DSCP(Differentiated Services Code Point),ECN(Explicit Congestion Notification) 原来这8字节是被定义成TOS(Type of Service),现在被 RFC2474 定义成 Differentiated services (差异化服务)和 ECN 。 背景:随着互联网的发展,各种各样的服务被提供,比如语音、视频、流音乐、网页、邮件等等。原来的TOS定义已经跟不上时代的需要,所以在1998年,IETF发布了RFC 2474,将原来的TOS替换成DSCP和ECN。 4. Total Length 整个数据包的长度,含头部,单位为Byte。 5. Identification 数据包标识,用来区分相同的包,比如ping包。 6. Flags bit 0 : 保留,总是0 bit 1 : Don’t Fragment, DF。表示不分片。当需要发送的数据大于最长数据包限制的时候,数据需要分片发送。如果这位置1,IP模块将不会对数据报进行分片。这种情况下

linux服务器优化2

别说谁变了你拦得住时间么 提交于 2020-01-16 10:19:52
临时修改服务器参数: sysctl -w 永久保存需要编辑 /etc/sysctl.conf close_wait状态出现的原因是client or server 发送了关闭信息给另一端,而另一端由于非正常关闭或者网络断开没有收到你发送的关闭连接信息等原因,使得发起close端,根据tcp/ip协议要保持存活一段时间。 $ /proc/sys/net/ipv4/tcp_keepalive_time $ /proc/sys/net/ipv4/tcp_keepalive_intvl $ /proc/sys/net/ipv4/tcp_keepalive_probes 这3个参数与TCP KeepAlive有关.默认值是: tcp_keepalive_time = 7200 seconds (2 hours) tcp_keepalive_probes = 9 tcp_keepalive_intvl = 75 seconds 意思是如果某个TCP连接在idle 2个小时后,内核才发起probe.如果probe 9次(每次75秒)不成功,内核才彻底放弃,认为该连接已失效.对服务器而言,显然上述值太大. 可调整到: /proc/sys/net/ipv4/tcp_keepalive_time 1800 /proc/sys/net/ipv4/tcp_keepalive_probes 3 /proc

Understanding IP . The requested URL was not found on this server

自古美人都是妖i 提交于 2020-01-16 07:05:29
问题 I'm a student, and I'm trying to understand the idea behind IP addresses. I learn that typing in a url is the same as typing in the corresponding IP address - either way, we'll be directed to the same web page. I used the ping command to find the IP address of howstuffworks.com . I then typed that IP address in my browser ( google chrome ) but got this error : The requested URL was not found on this server. Why? I tried the same with google.com IP, and it worked fine. Also, the IP addresses

网络高并发的问题

二次信任 提交于 2020-01-14 20:33:31
高并发下,http请求很重,会导致 tomcat 假死无相应 netstat -na | grep ESTAB | grep 80 tcp6 0 0 192.168.1.212:80 192.168.1.167:50210 ESTABLISHED tcp6 0 0 192.168.1.212:80 192.168.1.167:50209 ESTABLISHED vi /etc/sysctl.conf net.ipv4.tcp_keepalive_time = 1200 #表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟。 net.ipv4.ip_local_port_range = 5000 65000 net.ipv4.tcp_syncookies = 1 #表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭; net.ipv4.tcp_tw_reuse = 1 #表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭; net.ipv4.tcp_tw_recycle = 1 #表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。 net.ipv4.tcp_fin

MySQL IPv4 Validation implementation

泄露秘密 提交于 2020-01-14 19:42:08
问题 Hello guys it is my first post I am struggling here for the past two days in implementing validation for ipv4 address.... The problem is that the validation should be performed on database level and this makes it difficult for noob like me So I have to make : Validation of ipv4 address If the prefix somewhere in the ip is 0 I have to remove it (example : 123.013.221.011 should become 123.13.221.11) What I have so far in a trigger: This is not working as it is supposed to, so I am asking you

Android TCP/IP常见问题

柔情痞子 提交于 2020-01-14 04:25:09
1 TCP的6种标识 SYN:SYNchronous,建立联机 ACK:ACKnowledgement,确认 PSH:PuSH,传送 FIN:FINish,结束 RST:ReSeT,重置 URG:URGent,紧急 SEQ:SEQuence number,顺序号码 2 TCP 3次握手 2.1 Wireshark抓包分析 Wireshark抓包时,3次握手显示的是相对序列号/确认号。如果想要关闭相对序列号/确认号,可以选择Wireshark菜单栏中的 Edit -> Preferences ->protocols ->TCP,去掉Relative sequence number后面勾选框中的√即可。 原始的Seq和ACK的值都很大,为便于理解,使用相对值;有点类似于真值表。 Seq, ACK 0, 0 0, 1 1, 1 3次握手Wireshark过滤规则:tcp.flags.syn==1 or tcp.flags.ack==0 2.2 Linux内核3次握手和接受数据状态机 RFC 793 net/ipv4/tcp_input.c 服务端 - tcp_rcv_state_process() 客户端 - tcp_rcv_synsent_state_process() TCP server端完成最终的3次握手 - 一直处于TCP_LISTEN状态监听连接 in net/ipv4

Haproxy压测及参数调优

可紊 提交于 2020-01-14 00:32:56
Haproxy压测及参数调优 [root@3b9d411b-0a16-4bc4-acd8-10f71b997c29 etc]# ss -s&&free -g Total: 102008 (kernel 102040) TCP: 102003 (estab 101812, closed 56, orphaned 77, synrecv 0, timewait 0/0), ports 30060 Transport Total IP IPv6 * 102040 - - RAW 0 0 0 UDP 4 3 1 TCP 101947 101946 1 INET 101951 101949 2 FRAG 0 0 0 total used free shared buffers cached Mem: 7 2 5 0 0 0 -/+ buffers/cache: 2 5 Swap: 0 0 0 先看上面的信息: 这台机器已将建立10w个链接,最高压测到17w左右 但是内存和cpu都没有到达瓶颈 cpu和内存的原因可能是没有用ssl链接都是基于http链接计算量小的缘故,也有可能是vegeta 没有输出足够的压力源导致,后期会完善压测方法,由此说明我们haproxy还有更大潜力挖掘。 下面会介绍单个Haproxy机器上实现这种规模访问所需的配置,和详细的内核调优方法。 测试目标

linux高阶-Nginx(十)-参数优化

不打扰是莪最后的温柔 提交于 2020-01-13 23:34:20
默认的Linux内核参数考虑的是最通⽤场景,不符合⽤于⽀持⾼并发访问的Web服务器的定义,根据业务特点来进⾏调 整,当Nginx作为静态web内容服务器、反向代理或者提供压缩服务器的服务器时,内核参数的调整都是不同的 此处 针对最通⽤的、使Nginx⽀持更多并发请求的TCP⽹络参数做简单的配置,修改/etc/sysctl.conf来更改内核参数 net . ipv4 . ip_nonlocal_bind = 1 #允许⾮本地IP地址socket监听 net . ipv4 . ip_forward = 1 #开启IPv4转发 net . ipv4 . tcp_timestamps = 0 #是否开启数据包时间戳 net . ipv4 . tcp_tw_reuse = 0 #端⼝复⽤ net . ipv4 . tcp_tw_recycle = 0 #快速回收TIME_WAIT状态,⽤于⼤量TIME_OUT场景 fs . file - max = 1000000 #表⽰单个进程较⼤可以打开的句柄数 net . ipv4 . tcp_tw_reuse = 1 #参数设置为 1 ,表⽰允许将TIME_WAIT状态的socket重新⽤于新的TCP链接,这对于服务器来说意义重⼤,因为总 有⼤量TIME_WAIT状态的链接存在 net . ipv4 . tcp_keepalive_time =

How to use 'getaddrinfo' to choose default free port for all interfaces?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-13 17:58:32
问题 I'm trying to make a server to listen on both IPv4 and IPv6 in dual stack mode. I want the same port number for both IPv4 and IPv6 servers, and I want it to be on a random selection of port (using port "0") when I bind, each server get different port, and I want it to be the same. so I thought it should be done by the getaddrinfo function. But when I give it the "0" port it stays "0" in the addrinfo results, what cause each bind to give me different port number. My question : Is there a way