Chitika

Showing posts with label networking. Show all posts
Showing posts with label networking. Show all posts

Thursday, April 3, 2014

assign IPv6 address

sudo ifconfig eth0 inet6 add 2001:0db8:100:1:2:3:4:5/48

Wednesday, February 6, 2013

C# get fully qualified domain name

Use following code snippet to get fully qualified domain name of current machine:



string domainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
string hostName = Dns.GetHostName();
string fqdn = "";

if (!hostName.Contains(domainName))
    fqdn = hostName + "." + domainName;
else
    fqdn = hostName;

C# Auto detect default IP Address


Use following code snippet to automatically detect the default IP address:



  IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
                    if (localIPs != null &&
                        localIPs.Length > 0)
                    {
                        tbServerName.Text = (from localIP in localIPs
                                             where localIP.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork
                                             select localIP.ToString()).FirstOrDefault();
                    }
                    else
                    {
                        tbServerName.Text = "";
                    }