ipv4

how to do urlopen over ipv4 by default

不想你离开。 提交于 2019-12-10 22:46:26
问题 What is the way to do urlopen in python such that even if the underlying machine has ipv6 networking enabled, the request is sent via ipv4 instead of ipv6? 回答1: I had a look into the source code. Unfortunately, urllib.urlopen() seems to use httplib.HTTP() , which doesn't even allow setting a source address. urllib2.urlopen() uses httplib.HTTPConnection() which you could inherit from and create a class which by default sets a source address '0.0.0.0' instead of '' . Then you could somehow

IPv4 ping命令

自古美人都是妖i 提交于 2019-12-10 17:23:59
IPv4 ping命令 给一台 Linux 主机分配了一个 IPv4 的 IP地址,如何使用 ping命令 确定该 IP地址 能否 ping 通呢? 1、查看主机的 IPv4 的 IP地址信息 命令如下: ip addr | grep net 通过命令可以看到,该主机的 IPv6 的IP地址为: 192.168.254.117 2、使用 ping 命令 进行 ping IPv4 的 IP 命令如下: ping 192.168.254.117 执行命令后,可以看到该 IPv4 的 IP地址 可以 ping通。 PS: 强烈推荐 一款个人常用的 SSH客户端神器 MobaXterm ,比 Xshell 更好用,请参考如下博文: https://www.cnblogs.com/miracle-luna/p/12008869.html 如何 ping IPv6 的 IP地址 ,请参考如下博文: https://www.cnblogs.com/miracle-luna/p/12017740.html 希望能帮到大家,谢谢! 来源: https://www.cnblogs.com/miracle-luna/p/12017857.html

How to open a socket on a specific interface and receive both IPv4 and IPv6 traffic

这一生的挚爱 提交于 2019-12-10 16:42:20
问题 With IPv4 I can bind() to a specific address to select the interface that will be used to receive the packets (and in some case, also to send, but that's not the point). On a dual stack IPv6/IPV4 machine I have this problem: I can create a 6 socket and use it to receive 4 traffic, but if I want to bind to a specific interface, I have to choose an IP address to bind to. If I bind to an IPv6 address, I'll filter out all the IPv4 traffic and vice versa. How can I receive both IPv4 and IPv6

C# server that supports IPv6 and IPv4 on the same port

半城伤御伤魂 提交于 2019-12-10 15:55:28
问题 Is it possible to have a Socket that listens and accepts both IPv6 and IPv4 clients? I used a IPv6 socket in C# hoping that it would automatically be backwards compatible but IPv4 clients cause an invalid ip address exception. 回答1: Have a look here. You can accept IPv4 clients as well as IPv6 clients with the one server socket. 回答2: Set the socket's IPv6Only option to false : Socket MySocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); MySocket

Get exact size of IPv6 header including the extenstion headers

痴心易碎 提交于 2019-12-10 12:08:21
问题 If IPv4 is in question and I want to extract IP and ICMP header out of std::istream, first I get the initial 20 bytes, then check if the header lenght provided in the IPv4 header is larger than 20 bytes in order to extract any options. The next bytes are the ICMP packet. Using the header lenght value carried inside the IPv4 header I can see the expect size of the IP header. However how to get the exact size of IPv6 header? There is a payload value inside IPv6 header that includes the size of

Is network byte order pointless under IPv6?

拥有回忆 提交于 2019-12-10 10:45:34
问题 If we use a 32-bit integer to store an IPv4 address, then the byte order of the integer must be considered. However, as there is no built-in 128-bit integer type under almost all platforms, an IPv6 address must be stored into a byte array, so, I think the byte order is no longer a problem. Am I correct? Or is there a corresponding function htonlXXX for IPv6? 回答1: IPv6 does require network byte order for ipv6 addresses. hton and ntoh are all about converting the address from how you have it

How to convert IPv4-mapped-IPv6 address to IPv4 (string format)?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 09:36:59
问题 I have a struct sockaddr structure containing an IPv4-mapped-IPv6 address like ::ffff:10.0.0.1 . I want to obtain only the IPv4 version of it in a string (in this case, 10.0.0.1 ) in C programming language. How do I go about achieving it? 回答1: As your structure contains an IPV6 address, I'll assume your have a struct sockaddr * pointer (let's name it addrPtr ) pointing to a struct sockaddr_in6 structure. You can get the address bytes easily. const uint8_t *bytes = ((const struct sockaddr_in6

Linux内核优化

最后都变了- 提交于 2019-12-10 04:43:07
主要是指在Linux系统中针对服务应用而进行的系统内核参数调整,优化没有的标准, 根据实际需求优化才是最合适的。 1.编辑内核配置文件 vim /etc/sysctl.con 2.参数及简单说明 net.ipv4.tcp_fin_timeout = 2 #保持在FIN-WAIT-2状态的时间,使系统可以处理更多的连接。此参数值为整数,单位为秒。 net.ipv4.tcp_tw_reuse = 1 #开启重用,允许将TIME_WAIT socket用于新的TCP连接。默认为0,表示关闭。 net.ipv4.tcp_tw_recycle = 1 #开启TCP连接中TIME_WAIT socket的快速回收。默认值为0,表示关闭。 net.ipv4.tcp_syncookies = 1 #开启SYN cookie,出现SYN等待队列溢出时启用cookie处理,防范少量的SYN攻击。默认为0,表示关闭。 net.ipv4.tcp_keepalive_time = 600 #keepalived启用时TCP发送keepalived消息的拼度。默认位2小时。 net.ipv4.tcp_keepalive_probes = 5 #TCP发送keepalive探测以确定该连接已经断开的次数。根据情形也可以适当地缩短此值。 net.ipv4.tcp_keepalive_intvl = 15

Ubuntu 18.04/18.10快速开启Google BBR的方法

老子叫甜甜 提交于 2019-12-09 19:31:31
说明: Ubuntu 18.04 改变挺大的,内核直接升到了正式版 4.15 ,而 BBR 内核要求为 4.9 ,也就是说满足了,所以我们不需要换内核就可以很快的开启 BBR ,这里简单说下方法。 提示:Ubuntu 18.10依然可以用该方法开启BBR,而对于19.04、貌似官方直接给你开启了BBR,不需要重复开启了。 方法 1、修改系统变量 echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf 2、保存生效 sysctl -p 3、查看内核是否已开启BBR sysctl net.ipv4.tcp_available_congestion_control 显示以下即已开启: # sysctl net.ipv4.tcp_available_congestion_control net.ipv4.tcp_available_congestion_control = bbr cubic reno 4、查看BBR是否启动 lsmod | grep bbr 显示以下即启动成功: # lsmod | grep bbr tcp_bbr 20480 14 来源: https://www.cnblogs.com

Use of IN6ADDR_SETV4MAPPED and dual stack sockets

大兔子大兔子 提交于 2019-12-09 13:46:20
问题 This is a continuation of Connecting IPv4 client to IPv6 server: connection refused. I am experimenting with dual stack sockets and trying to understand what setsockopt with IPV6_V6ONLY is useful for. On the linked question I was advised that "Setting IPV6_V6ONLY to 0 can be useful if you also bind the server to an IPv6-mapped IPv4 address". I have done this below, and was expecting my server to be able to accept connections from both an IPv6 and an IPv4 client. But shockingly when I run my