Thursday, November 22, 2012
C# Get IPV4 ipaddress
Option 1 :
public static string GetIP4Address()
{
string IP4Address = String.Empty;
foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (IPA.AddressFamily == AddressFamily.InterNetwork)
{
IP4Address = IPA.ToString();
break;
}
}
return IP4Address;
}
Option 2 :
/// <summary>
/// This utility function displays all the IP (v4, not v6) addresses of the local computer.
/// </summary>
public static void DisplayIPAddresses()
{
StringBuilder sb = new StringBuilder();
// Get a list of all network interfaces (usually one per network card, dialup, and VPN connection)
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface network in networkInterfaces)
{
// Read the IP configuration for each network
IPInterfaceProperties properties = network.GetIPProperties();
// Each network interface may have multiple IP addresses
foreach (IPAddressInformation address in properties.UnicastAddresses)
{
// We're only interested in IPv4 addresses for now
if (address.Address.AddressFamily != AddressFamily.InterNetwork)
continue;
// Ignore loopback addresses (e.g., 127.0.0.1)
if (IPAddress.IsLoopback(address.Address))
continue;
sb.AppendLine(address.Address.ToString() + " (" + network.Name + ")");
}
}
MessageBox.Show(sb.ToString());
}
Tuesday, November 20, 2012
Windows Domain Controller NTP 設定
DC NTP對時的方式需透過GPO來設定, 修改Registry是無效的
開啟GPO->電腦設定->系統管理範本->系統->Windows時間服務->時間提供者
要去向別人校時就必須啟用『Windows NTP用戶端』
要給別人校時就必須啟用『Windows NTP伺服器』
在『設定Windows NTP用戶端』內設定NTP Server
NoSync: The client does not synchronize time.
NTP: The client synchronizes time from an external time source. Review the values in the NtpServer line in the output to see the name of the server or servers that the client uses fortime synchronization.(其他外部NTP Server)
NT5DS: The client is configured to use the domain hierarchy for its time synchronization.(當電腦在Domain內時使用)
AllSync: The client synchronizes time from any available time source, including domainhierarchy and external time sources.(任一種皆可)
所以DC角色就是全開, 因為他要當Domain User的NTP Server, 又要當NTP Client去跟中華電信校時
另外, 有遇到網路設備無法跟Windows NTP Server校時的問題
因為w32tm使用的是sntp與一般unix, linux及網路設備懂的ntp不同, 所以無法校時
解法就是別用w32tm......
Subscribe to:
Comments (Atom)