Select IP Addresses which use a specific port - web

My idea here is create a website where the user is able to click a button which will look into the IP Addresses to see which one is using a certain port, for example:
I want to search for the IP Addresses which are communicating with the localhost that are using the port #3620 (which is obviously being used) and a code will show all the IP Addresses.
My question here is to see if this is possible and if it is, can someone give a brief idea of how this could be done?

For seeing if a port is open check out this:
In C#, how to check if a TCP port is available?
You could even loop over all port numbers for an IP address and check to see what ones are open.
TcpClient tcpClient = new TcpClient();
try
{
tcpClient.Connect("127.0.0.1", 9081);
Console.WriteLine("Port " + 9081+ " Open");
}
catch (Exception)
{
Console.WriteLine("Port " + 9081+ " Closed");
}

Related

how to make an exchange of messages between two different computers in the same network?

How can have the simple exchange of message between two different computer
code of interface is:
interface MyInterface{
RequestResponse: Doppio(int)(int)
}
code of client is:
include "MyInterface.ol"
include "console.iol"
outputPort B {
Location: "socket://192.168.1.145:8000"
Protocol: http
Interfaces: MyInterface
}
main{
Doppio#B(5)(response);
print#Console(response)()
}
code of server is:
execution { concurrent }
include "MyInterface.ol"
inputPort B {
Location: "socket://192.168.1.145:8000"
Protocol: http
Interfaces: MyInterface
}
main {
Doppio(x)(Dop)
{
Dop=x*2
}
}
the code works because is the same PC and same IP address, but with 2 PC (with their IP address) doesn't work!
for me the problem is the socket but I don't know, help me please
In order to provide a temptative answer, I need to know, at least, two things:
basic network setup;
error message from the execution of the commands jolie server.ol and jolie client.ol.
Tip: pick an IP address of a different device connected to the same network, such as 192.168.1.xxx, and provide the result of ping 192.168.1.xxx. Also, the network/firewall should allow for incoming connections to the port you would choose (for instance 8000, as in the code snippet above).

Node.js dns.resolve not returning correct IP address

I'm trying to use Node.js DNS resolve to look up an IP address of a domain that belong to me (let's call it host.mydomain.com). If the lookup for host.mydomain.com is done from the server that host.mydomain.com actually points to, it returns the server's local NIC IP address (192.168.0.10) instead of the server's external IP address.
Doing a host lookup for host.mydomain.com from an external machine using the same code returns the expected external IP address. More importantly, I have a different server in another environment, call it host.otherdomain.com, that does correctly return its own external IP address when doing a lookup, using the same code.
I do not have anything in my hosts file that would override this. Both domains are from the same DNS provider, and both are wildcard domains.
My code:
var dns = require('dns');
dns.setServers([ "8.8.8.8", "8.8.4.4" ]);
domain="host.mydomain.com";
dns.resolve(domain, function (error, addresses) {
console.log("Error: ", error); // null
console.log("DNS servers: ", dns.getServers()); // [ '8.8.8.8', '8.8.4.4' ]
console.log(domain + " resolves to: ", addresses); // [ '192.168.0.10' ]
});
I'm currently using Node.js 6 on all servers.
In my case the problem turned out to be with the IBM datacenter where the machine was hosted. It was running on a modded vCenter setup their staff had set up, and was doing funky things with DNS. I know vCenter has Linux guest integration, I'm unsure if this was part of the problem.
So in short I guess the solution is to ensure your environment (in my case the datacenter) isn't messing you around.

Telnet Port connectivity from one server to another through JSP

Hi All,
I want to create a JSP page where I will ask user to give the source host and port and also destination host and port.
Following combination of source and destination OS is possible
Unix->Unix/Windows/zOS Windows-> Unix/Windows/zOS zOS ->
Unix/Windows/zOS
With these inputs I want to connect to the source server and fire this command telnet $ip $port to the destination. If the telnet connectivity is successful it should return success and else error.
I want to create the logic non-interactive that it should not require any password to login the source for checking telnet connectivity.
Is there any such library or any mechanism available so that I could make this feasible?
Why not use Apache Commons Net?
TelnetClient telnet = new TelnetClient();
try {
telnet.connect("rainmaker.wunderground.com", 3000);
} catch(IOException e) {
// failed
} finally {
telnet.disconnect();
}

How do I correctly set up my UdpClient to listen on the multicast address 239.255.255.250:1900 in C#

I am setting up a small local network with 3 laptops. My goal is to experiment with the UpNP protocol and have the laptops discover each other using UpNP. In order to do this, they need to be able to listen for notifications from each other. As per the protocol, these notifications are sent on multicast address 239.255.255.250:1900. However, I am having a problem setting the laptops up to listen on that address. I am starting just using 1 pc. My PC's IP address is 10.0.0.5.
However, when I try to set up a UdpClient to listen on 239.255.255.250:1900 I get an error saying: "The requested address is not valid in its context".
I have tried just setting it up using this:
IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("239.255.255.250"), 1900);
UdpClient client = new UdpClient(endpoint);
client.BeginReceive(MessageReceived, null);
I have also tried:
UdpClient client = new UdpClient(Port);
client.JoinMulticastGroup(IPAddress.Parse("239.255.255.250"));
client.BeginReceive(MessageReceived, null);
But I still get the same error: "The requested address is not valid in its context".
How do I correctly set up my UdpClient to listen on the multicast address 239.255.255.250:1900 ?
Thanks for your help!!!
Ok, after much searching and banging my head on my desk, I've got this thing working. I thought I had it working yesterday, but it only worked on Windows 7 and not on XP..
So, here it goes:
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, Port);
UdpClient client = new UdpClient();
client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
client.Client.Bind(localEndPoint);
client.JoinMulticastGroup(IPAddress);
client.MulticastLoopback = true;
Client.BeginReceive(MessageReceived, null);
I sure wish this was documented a bit better, but I guess that's why we get the big bucks $$$.
Thanks StackOverflow for providing such an AWESOME knowledgebase from which to extract this stuff !!

How to Get WebSite IP that doesn't Answer Pings?

I'm trying to get the IP address of a website that does not respond to pings -- they time out.
I'm trying to do this from a C# application rather than the command entry screen in windows. I've been using the ping command which has times out on some sites so it is not useful there.
Is there another way to get this information that does not require the site to respond?
Even if the site does not respond to PINGs (ICMP not enabled on the server or filtered by firewall), the PING command should still resolve the site name into an IP address and display that IP address to you.
Check the output of a ping command on Windows (the ip address in bold):
ping wikipedia.org
Pinging wikipedia.org [208.80.152.2] with 32 bytes o
Reply from 208.80.152.2: bytes=32 time=245ms TTL=50
Reply from 208.80.152.2: bytes=32 time=235ms TTL=50
Update (due to to updated question)
If you are trying to get the IP address for DNS name from a C# application, you should use the GetHostEntry method from the Dns class: http://msdn.microsoft.com/en-us/library/ms143998.aspx .
You get IP from DNS, and need it to perform a ping, so you have it already.
$ ping google.com
PING google.com (74.125.227.51) 56(84) bytes of data.
64 bytes from 74.125.227.51: icmp_seq=0 ttl=56 time=5.80 ms
64 bytes from 74.125.227.51: icmp_seq=1 ttl=56 time=6.23 ms
The IP is shown. If you aren't getting an IP, your DNS might be down.
You can also try nslookup google.com
To get an IP address from a host name in Dns.GetHostEntry(). Pass in the host name and it will return you the IP address.
There is no reason you need to ping (on anyway contact) a site to get it's IP address. A DNS lookup will give you what you need.
You can use nslookup to resolve domain names.
nslookup google.com
The following code can be used to execute a DNS lookup for the supplied host name.
Using DNS will bypass accessing the target server. It is an independant distributed directory service that maintains hostname to IP address lookups.
The following code will give the first returned IP address for a host if a DNS entry can be resolved for the supplied host name.
public void test()
{
string hostname = "google.com";
IPAddress ipAdress;
if (TryGetIpAddress(hostname, out ipAdress))
{
Console.WriteLine("Host:'{0}', IP:{1}.", hostname, ipAdress);
}
else
{
Console.WriteLine("Host '{0}' not found.", hostname);
}
}
public bool TryGetIpAddress(string hostname, out IPAddress ipAddress)
{
const int HostNotFound = 11001;
ipAddress = null;
try
{
IPHostEntry hostEntry = Dns.GetHostEntry(hostname);
ipAddress = hostEntry.AddressList[0];
}
catch (SocketException ex)
{
if (ex.ErrorCode != HostNotFound) throw;
}
return (ipAddress != null);
}
You can use tracert and it will resolve the IP address and tell you if it can be reached or where it stops.
If site (http) is up and running then it is very well clear that the sys/network admin disabled ping and most probably trace route utility too. It is getting very common now. See here. Your alternative is to use ns lookup or WHOIS service as described here
Doing this in code you should have some function like gethostbyname().
This should be on stackoverflow.com
untested
You could host this website
http://centralops.net/co/DomainDossier.aspx
you could use import.io to make functinality with the site.
https://www.import.io/
this links could give you an insight

Resources