ipv4

How do I determine the local host’s IPv4 addresses?

吃可爱长大的小学妹 提交于 2019-11-26 20:20:53
问题 How do I get only Internet Protocol version 4 addresses from Dns.GetHostAddresses() ? I have the code below, and it gives me IPv4 and IPv6 addresses. I have to make it work with boxes that have multiple IPv4 addresses. IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); private void get_IPs() { foreach (IPAddress a in localIPs) { server_ip = server_ip + a.ToString() + "/"; } } 回答1: add something like this to your code if( IPAddress.Parse(a).AddressFamily == AddressFamily

Validate IPv4, IPv6 and hostname

白昼怎懂夜的黑 提交于 2019-11-26 20:17:24
问题 I'm working on a project in .net , that can connect to different machines by an IP address that the user inputs. I'm trying to validate the inputted IP Address using a regular expression. I've searched the internet for some time now, and i cannot get a proper regex. I've wrote a little program to test the regex, see here,(the IP addresses were generated randomly, I'm sorry if some of the IP Addresse belongs to someone) Can you help me find a viable solution, in validating on client side the

WARNING: IPv4 forwarding is disabled. Networking will not work.

不想你离开。 提交于 2019-11-26 20:10:24
centos7.4 启动docker容器报网络错误 报错: [root@lvhanzhi ~]# docker run -it centos:7.4.1708 WARNING: IPv4 forwarding is disabled. Networking will not work. #导致后面容器上不了外网 解决方法: [root@lvhanzhi ~]# vim /usr/lib/sysctl.d/00-system.conf net.ipv4.ip_forward=1 #加入这一条 [root@lvhanzhi ~]# systemctl restart network #重启网卡 [root@lvhanzhi ~]# docker run -it centos:7.4.1708 #重新启动容器 来源: https://www.cnblogs.com/lvhanzhi/p/11332306.html

How to support both IPv4 and IPv6 connections

纵饮孤独 提交于 2019-11-26 18:54:06
问题 I'm currently working on a UDP socket application and I need to build in support so that IPV4 and IPV6 connections can send packets to a server. I was hoping that someone could help me out and point me in the right direction; the majority of the documentation that I found was not complete. It'd also be helpful if you could point out any differences between Winsock and BSD sockets. Thanks in advance! 回答1: The best approach is to create an IPv6 server socket that can also accept IPv4

Script to change ip address on windows

梦想与她 提交于 2019-11-26 18:14:55
问题 I use my computer to communicate with a piece of hardware via ethernet. To communicate with this device I set my ip to 192 168 0 11, subnet mask to 255 255 255 0, and default gateway to 192 168 0 1 for IPv4. To use the internet, I choose "Obtain an IP address automatically" via control panel. I'd like to have a script that allows my to quickly choose one or the other ethernet setting - hardware or internet. I program mostly in python but maybe there is a batch file solution. Thanks, Barry.

What is the most appropriate data type for storing an IP address in SQL server? [duplicate]

旧街凉风 提交于 2019-11-26 17:57:23
问题 This question already has an answer here: Datatype for storing ip address in SQL Server 10 answers What should be the most recommended datatype for storing an IPv4 address in SQL server? Or maybe someone has already created a user SQL data-type (.Net assembly) for it? I don't need sorting. 回答1: Storing an IPv4 address as a binary(4) is truest to what it represents, and allows for easy subnet mask-style querying. However, it requires conversion in and out if you are actually after a text

mysqlslap压力测试时出现\"Can't connect to MySQL server\"

﹥>﹥吖頭↗ 提交于 2019-11-26 17:27:18
mysqlslap -utest -h 192.168.1.12 -p'test' --concurrency=100 --iterations=500 --create-schema='my_db' 结果压了10来秒,就频繁报告 mysqlslap: Error when connecting to server: 2003 Can't connect to MySQL server 这时用netstat -tnp查看tcp连接,发现有2万多的tcp连接,全部停留在time_wait状态。怀疑是端口用尽了。网上查了一下资料,发现一篇文章提供的信息很有用 http://blog.csdn.net/fanyun7654/article/details/20725783 程序可用的端口范围,是一个内核参数 shell> sysctl -a | grep port net.ipv4.ip_local_port_range = 32768 61000 解决的办法 一、加大端口范围,不过作用有限 shell> echo "net.ipv4.ip_local_port_range = 10240 61000" >> /etc/sysctl.conf shell> sysctl -p 二、允许端口重用 sysctl net.ipv4.tcp_tw_reuse=1 或者 net.ipv4.tcp

Centos 升级内核安装 BBR 简易操作!

非 Y 不嫁゛ 提交于 2019-11-26 16:40:31
BBR 的描述: Google 开源了其 TCP BBR 拥塞控制算法,并提交到了 Linux 内核,从 4.9 开始,Linux 内核已经用上了该算法。根据以往的传统,Google 总是先在自家的生产环境上线运用后,才会将代码开源,此次也不例外。 根据实地测试,在部署了最新版内核并开启了 TCP BBR 的机器上,网速甚至可以提升好几个数量级。 要在CentOS 上安装最新的内核版本,需要增加一个 ELRepo 源。 首先,载入公钥,让我们添加 ELRepo GPG key: # rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 为 RHEL-6,SL-7或CentOS-7 源: # rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm 安装 fastestmirror # yum install yum-plugin-fastestmirror 安装kernel 最新版 # yum --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel 将kernel-ml 选为第一启动 # grub2-set-default 0 重启服务器 # reboot 重启后

API for configuring static IP addresses in an Android application

橙三吉。 提交于 2019-11-26 13:53:38
问题 Is it possible to set the IP address of an interface in Android within an application? I can query the available interfaces and their current addresses using java.net.NetworkInterface , but this doesn't provide a facility to change these. Did I just miss something somewhere, or is it not allowed? I was hoping to be able to make my application either change or add an alias to one or more of the existing interfaces at runtime on an "off the shelf" device. (2.1/2.2). Ideally I'd like to do this

Get destination address of a received UDP packet

爷,独闯天下 提交于 2019-11-26 12:21:21
Upon receiving a UDP packet, I need to respond to the sender with the address he used to send the packet to which I'm replying. The recvfrom call lets me get the address of the sender, but how do I get the destination address of the received packet, which should match the address of one of the local host's interfaces? You set the IP_PKTINFO option using setsockopt and then use recvmsg and get a in_pktinfo structure in the msg_control member of struct msghdr. the in_pktinfo has a field with the destination address of the packet. See: http://www.linuxquestions.org/questions/programming-9/how-to