ipv4

IP-Configuration from Batch file

巧了我就是萌 提交于 2019-12-25 02:19:55
问题 @echo off set /p option=(1) Edit IP (2) Enable DHCP: if %option%==1 ( set /p IP=New IP-Address: set /p MASK=New Network Mask: set /p GATE=New Gateway Address: netsh interface ip set address name="LAN" static %IP% %MASK% %GATE% 1 ) if %option%==2 ( netsh interface ip set address name="LAN" source=dhcp ) pause The DHCP part of the program works just fine. The NIC's name is "LAN". I have tried with and without the 1 paramenter on the set IP. I have also tried with different variable names. The

LeetCode 468. 验证IP地址

穿精又带淫゛_ 提交于 2019-12-24 00:22:52
1. 题目 编写一个函数来验证输入的字符串是否是有效的 IPv4 或 IPv6 地址。 IPv4 地址由十进制数和点来表示,每个地址包含4个十进制数,其范围为 0 - 255, 用(".")分割。比如,172.16.254.1; 同时, IPv4 地址内的数不会以 0 开头 。比如,地址 172.16.254.01 是不合法的。 IPv6 地址由 8组 16进制的数字来表示,每组表示 16 比特。这些组数字通过 (":")分割。比如, 2001:0db8:85a3:0000:0000:8a2e:0370:7334 是一个有效的地址。而且,我们可以加入一些以 0 开头的数字,字母可以使用大写,也可以是小写。所以, 2001:db8:85a3:0:0:8A2E:0370:7334 也是一个有效的 IPv6 address地址 (即,忽略 0 开头,忽略大小写)。 然而,我们不能因为某个组的值为 0,而使用一个空的组,以至于出现 ( :: ) 的情况。 比如, 2001:0db8:85a3::8A2E:0370:7334 是无效的 IPv6 地址。 同时,在 IPv6 地址中, 多余的 0 也是不被允许的 。比如, 02001:0db8:85a3:0000:0000:8a2e:0370:7334 是无效的。 说明: 你可以认为给定的字符串里没有空格或者其他特殊字符。 示例 1 : 输入

CentOS7 内核优化 修改参数

寵の児 提交于 2019-12-23 18:46:54
一:内核简介 内核是操作系统最基本的部分。它是为众多应用程序提供对计算机硬件的安全访问的一部分软件,这种访问是有限的,并且内核决定一个程序在什么时候对某部分硬件操作多长时间。 内核的分类可分为单内核和双内核以及微内核。严格地说,内核并不是计算机系统中必要的组成部分。 什么是内核? 内核,是一个操作系统的核心。是基于硬件的第一层软件扩充,提供操作系统的最基本的功能,是操作系统工作的基础,它负责管理系统的进程、内存、内核体系结构、设备驱动程序、文件和网络系统,决定着系统的性能和稳定性。 二:查看系统资源 1.查看当前系统的所有限制值 命令:ulimit -a 2.查看用户同时打开的文件数(linux系统默认的只要1024) 命令:ulimit -n 3.ulimit的选项用法 -a  显示目前资源限制的设定 -c <core文件上限>  设定core文件的最大值,单位为区块 -d <数据节区大小>  程序数据节区的最大值,单位为KB -f <文件大小>  shell所能建立的最大文件,单位为区块 -H  设定资源的硬性限制,也就是管理员所设下的限制 -m <内存大小>  指定可使用内存的上限,单位为KB -n <文件数目>  指定同一时间最多可开启的文件数 -p <缓冲区大小>  指定管道缓冲区的大小,单位512字节 -s <堆叠大小>  指定堆叠的上限,单位为KB -S

Regular expression to validate InetSocketAddresses (ipv4/v6 + port addresses)

亡梦爱人 提交于 2019-12-23 16:50:53
问题 I am looking for tested regular expressions for both ipv4 and ipv6 InetSocketAddress (i.e., ip address + port number). I am not interested in validating hostnames. It can be two regex (one for ipv4, one for ipv6) or one combined regex. Does anyone have any to share? EDIT For ip4 format information see here, for ipv6 format information see here. Then, port number is added with ':'. EDIT 2 To create a string representation, I will proceed like this: byte[] tmp = { 10, 1, 0, 0 };

WSAStringToAddress failing

白昼怎懂夜的黑 提交于 2019-12-23 15:30:08
问题 I'm trying to populate a sockaddr_in structure from an IPv4 string address using the following C++ code: // WSAStringToAddress struct sockaddr_in sock; int addrSize = sizeof( struct sockaddr_in ); memset( &sock, 0, addrSize ); sock.sin_family = AF_INET; rc = WSAStringToAddress( (LPWSTR) "192.168.0.1", AF_INET, NULL, (LPSOCKADDR) &sock, &addrSize ); if ( rc != 0 ) { rc = WSAGetLastError(); printf( "WSAStringToAddress: error=[%d]\n", rc ); } It is failing with error code 10022, which is

Force InetAddress.getHostAddress() to return IPv4 address

耗尽温柔 提交于 2019-12-23 12:37:58
问题 I'm using a library that uses java.net.InetAddress.getLocalHost().getHostAddress() to get my local IP address. However, this always returns an IPv6 address on my computer (Gentoo Linux, JDK 1.6.0_37). The address is further used in a context which does not support IPv6 addresses and thus fails. Is there some way to force getHostAddress() to return a IPv4 address (e.g. through a parameter to JVM)? 回答1: You can set it to use IPv4 when avaiable. Of course, there are a great number more IPv6

Is there a standard .NET decoder for ipv4 and ipv6 addresses?

蓝咒 提交于 2019-12-23 11:36:11
问题 I'd like to write a fairly simple client-server network app. I only use a pure IPv4 network, but it would be nice to future-proof my code. I'll probably be using TcpListener/TcpClient, because preliminary investigation of WCF reveals it to be overly complex to set up and hard to grok. For the client side, does .NET provide a facility to automatically decode a string that contains an IPv4 or IPv6 address (where the IPv4 address includes a port number)? Bonus points if it can resolve a domain

Spring boot application listens over IPv6 without -Djava.net.preferIPv4Stack=true and -Djava.net.preferIPv4Addresses parameters

柔情痞子 提交于 2019-12-23 10:50:45
问题 My question about Spring boot jar. When running jar on production machine as: java -jar xyz.jar It does not respond to my request. Because it is listening on ipv6. But when I run application as java -jar xyz.jar -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses It responds my requests. Is it the production machine's configuration which cause the application to listen over ipv6, or is there any other reasons? Fortunately -Djava.net.preferIPv4Stack=true -Djava.net

Java regex for accepting a valid hostname,IPv4, or IPv6 address

こ雲淡風輕ζ 提交于 2019-12-22 05:15:16
问题 Anyone have a good (preferably tested) regex for accpeting only a valid DNS hostname, IPv4 or IPv6 address? 回答1: I understand that you may be forced to use a regex. However, if possible it is better to avoid using regexes for this task and use a Java library class to do the validation instead. If you want to do validation and DNS lookup together, then InetAddress.getByName(String) is a good choice. This will cope with DNS, IPv4 and IPv6 in one go, and it returns you a neatly wrapped

How can I get a hostname from an IPv4 address in C?

岁酱吖の 提交于 2019-12-21 21:48:58
问题 I need a simple function that outputs a char* hostname , given a char* IPAddress . Any ideas or hints? Also, is easiest way to get the IP address from a hostname is gethostbyname() and inet_ntoa() is that correct? 回答1: Use gethostbyaddr() or getnameinfo() to convert an IP into a hostname. Use gethostbyname() or getaddrinfo() to convert a hostname into an IP. gethostby...() only support IPv4. get...info() support multiple protocols including both IPv4 and IPv6, and are the preferred functions