import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; public class MyTest { public static void main(String[] args) throws Ex…
1.获取内网Ip private String getLocalhostIp(){ String hostAddress = ""; try { InetAddress address = InetAddress.getLocalHost(); hostAddress = address.getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); } return hostAddress; } 2.…
https://jingyan.baidu.com/article/48b558e335e3ac7f39c09a59.html 步骤: 1.浏览器内输入:192.168.1.1进入路由器管理界面 2.选择虚拟服务器,这里的ip地址设置成主机本地ip,端口是运行的程序使用的端口,如果是Windows远程连接,搜索对应端口填写即可: 3.保存退出 连接: linux系统(如果是Windows,可以使用git bash) 命令行模式输入:curl ifconfig.me,获取访问外网使用的ip地址 在…
1.获取本机的IP地址集合: /// <summary> /// 获取本机所有ip地址 /// </summary> /// <param name="netType">"InterNetwork":ipv4地址,"InterNetworkV6":ipv6地址</param> /// <returns>ip地址集合</returns> public static List&l…
转自:http://blog.163.com/houjunchang_daxue/blog/static/13037938320134543310451/ /** * 获取外网IP.归属地.操作系统 * @return */ public static String[] getIp(){ String[] obj = new String[3]; StringBuffer strForeignIP = new StringBuffer(""); StringBuffer strLoca…
在工作时,需要获取服务器公网IP(外网IP),并且判断该IP地址是属于网通还是电信.花时间整理一下,自己实现的代码,以及后续遇到的问题. /// <summary> /// 获取外网IP /// </summary> /// <returns>IP</returns> public static string GetOuterIP() { string IP = string.Empty; Uri uri = new Uri("http://www…
Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer   Advanced Installer :Free for 30 days. All features.下载地址:https://www.advancedinstaller.com/download.html30天内免费汉化版:http://www.jb51.net/softs/595612.html 选择Visual Studio应用,点击创建项目 可以输入应用名称…
1.如果你是通过路由上网的,可以通过访问ip138之类的地址来获取外网IP 2.如果是通过PPPOE拨号上网的,可以使用以下代码获取IP //获取宽带连接(PPPOE拨号)的IP地址,timeout超时(秒),当宽带未连接或者连接中的时候获取不到IP public static string GetIP_PPPOE(int timeout) { int i = timeout * 2; while (i > 0) { try { NetworkInterface[] nics = Network…
获取外网IP:curl -s ifconfig.me…
很多情况下我们需要获取外网的IP地址,一般用自带的方法获取到的都是不准确,往往获取到的是内网的IP地址,所以需要采用外部网站接口来获取. 代码 通过访问第三方接口来获取真实的ip地址 public static string GetIPAddress() { string ip = ""; try { WebClient MyWebClient = new WebClient(); MyWebClient.Credentials = CredentialCache.DefaultCre…