This question already has answers here:
How to perform "nslookup host server"
(4 answers)
Closed 9 years ago.
In my application, I should get the domain names of the few IP Addresses I give as Input. I guess this process is called NSLOOKUP. However, I would like to confirm if I'm right. Simple program to implement this and display a MessageBox output is what I look for.
Contributions please...
Thank you in anticipation
IPAddress address = IPAddress.Parse("127.0.0.1");
IPHostEntry entry = Dns.GetHostEntry(address );
Console.WriteLine(entry.HostName);
Related
This question already has answers here:
How to get IP of all hosts in LAN?
(8 answers)
Closed 3 years ago.
How do I get all the IP addresses with device's name that are connected on the same network? So far I have only seen getting local IP address of one's device.
if you have the device name you can use this...
IPAddress[] IpInHostAddress = Dns.GetHostAddresses("PCNAME");
strIpAddress = IpInHostAddress[0].ToString();
This question already has answers here:
Request.UserHostAddress issue with return result "::1"
(4 answers)
Closed 9 years ago.
I have a login page where the user can login to my website when the user click on the submit button in the login page I want to read it's Ip address how ca i do this is c# I tried this
Request.UserHostAddress;
but the result was ::1 is it because I am logging in from the local machine or the statement that I used above is wrong?
That's basically the IPv6 version of 127.0.0.1 so is technically correct. If you don't use or need IPv6 disable it in the network adapter settings.
::1 is the IPv6 address, your code is correct.
See this answer for details.
This question already has answers here:
How do I get the local machine name in C#?
(5 answers)
How do I get the computer name in .NET
(12 answers)
Closed 8 years ago.
How can I get a part of a system's name? For instance if the computer name contains SERVER then do something, and if it includes CLIENT then do something else.
The names I an working with are similar to SERVER000455. The numerical values change all the time but the SERVER part is the same.
Getting the name is easy (SystemInformation.ComputerName), but that wasn't my question. My question was getting just the first part of the name. The string[] and split doesn't seem to work since it's not an array. I just need to get the prefix of the PC name and drop the numerical bit.
Okay, I thought the main question was the computer name. But you want:
String machinename = System.Environment.MachineName;
if(machinename.ToUpper().Contains("SERVER"))
{
}
else if (machinename.ToUpper().Contains("CLIENT"))
{
}
if (Environment.MachineName.ToUpper().Contains("SERVER"))
{
// etc.
}
This question already has answers here:
how to change originating IP in HttpWebRequest
(2 answers)
Closed 9 years ago.
is it possible to change orginating IP in HTTPWebRequest C# and provide any Custom/fake IP?
You could try out the following Libraries
PCap.NET Referenced from IP address spoofing using PCap.NET
sharppcap Referenced from C# How to spoof IP address for WebRequest
This question already has answers here:
How do I get process name of an open port in C#?
(4 answers)
Closed 9 months ago.
I need a way of, given a tcp port number, discover if there's some process using that port (and get the process id).
Something like netstat does but programmatically.
This is probably too late for the original poster but someone else may find it useful. You can use the PowerShell class in the System.Management.Automation namespace.
private static IEnumerable<uint> ProcessesUsingPorts(uint id)
{
PowerShell ps = PowerShell.Create();
ps.AddCommand("Get-NetTCPConnection").AddParameter("LocalPort", id);
return ps.Invoke().Select(p => (uint)p.Properties["OwningProcess"].Value);
}