Created
April 13, 2016 14:57
-
-
Save Thorium/17184252d0284b78b63ef65e692d670b to your computer and use it in GitHub Desktop.
Get local IPv4-address of the computer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System; | |
open System.Net; | |
open System.Net.NetworkInformation; | |
let GetLocalIpv4Address() = | |
let interfaces = NetworkInterface.GetAllNetworkInterfaces() | |
let unicastAddresses = | |
interfaces |> Seq.map (fun i -> i.GetIPProperties().UnicastAddresses) |> Seq.concat |> Seq.toList | |
let item = | |
unicastAddresses |> Seq.find (fun a -> a.IPv4Mask.ToString() <> "0.0.0.0" && a.IPv4Mask.ToString() <> "255.0.0.0") | |
//|> Seq.find (fun a -> a.PrefixLength = 16) | |
item.Address.ToString() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment