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
Related
I have set up a linux server and configured the dns named service (LINDNS1). This will serve as the primary DNS for all internal clients. The only job it will do is to forward all the queries to the existing Windows DNS servers (WINDNS1 and WINDNS2).
So, when the client query goes to LINDNS1, it will forward the query to WINDNS1 if it can't find a record, it will forward the query to WINDNS2. If the record is in WINDNS2, it will answer the query.
I have set the forwarder settings on the dns configuration files. But it is not working.
named.conf #not much change here except for the standard settings.
listen-on port 53 { 127.0.0.1; LINDNS1 IP address; };
allow-query { localhost; any; }; #I just put 'any' for now while it's in a testing phase.
allow-query-cache { localhost; any; };
recursion yes;
The forwarding configuration is set in the named.rfcxxxx.zone file. I have included the reverse zones as well.
zone "test.net" IN {
type forward;
forwarders { 1.1.1.1; 2.2.2.2; };
};
Clients don't have any problem issuing nslookup, LINDNS1 can respond and can query records in WINDNS1 (1.1.1.1). But when querying a record that is in WINDNS2 (2.2.2.2), it returns that it can't find the host.
So, when the client query goes to LINDNS1, it will forward the query to WINDNS1 if it can't find a record, it will forward the query to WINDNS2. If the record is in WINDNS2, it will answer the query.
No. When LINDNS receives the answer NXDOMAIN from WINDNS1 it has no reason to ask other servers again about this record.
In your case WINDNS2 will be queried only if WINDNS fails (server is down, named is not running, etc)
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.
Good day everyone!
I am making a DHCP Server for a project. I tried it in Windows and it worked. Now, I need to make it work on Linux. I used the same code and it can listen packets coming from port 67. However, every time I am about to send packets to the machine in KVM (Kernel Virtual Machine), I get an error at line containing "datagramsocket.send(response)" saying that Network is Unreachable. Btw, I am using a centOS as host and another centOS as guest machine. Bridge connection and firewall is disabled. How could I fix this problem? I am clueless.
Thanks in advance! :)
I used a dhcp4java API and here's a portion of my code:
if (replypacket != null){
InetAddress add = replypacket.getAddress();
int port = replypacket.getPort();
byte[] buf = replypacket.serialize();
DatagramPacket response = new DatagramPacket(buf, buf.length, add, port);
datagramsocket.send(response);
}
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");
}
I have a WebLogic 11g domain with 1 admin server and 4 managed servers running on 2 machines. Each machine has 3 ip addresses, but only one of those addresses is seen by another machine. Each machine is running a node manager which seems to communicate fine between each other and admin server. Though when managed server starts on the second machine it can't communicate to admin server because it uses wrong ip address. It appears that when weblogic starts it maps itself to all ip addresses, but selects wrong one as the first one i.e. default. That's why managed servers recieve wrong information from node manager.
Is there a way to set preffered listen address in weblogic 11g, but still allow it to listen to all other addresses either? How does weblogic get list of ip addresses? Is the order of them OS-dependent?
Does this answer the question? I believe if you play with the scripts in /etc/sysconfig, you'll affect the loading order and thence the enumeration order. I must admit, I don't have a RH box here to confirm that suspicion.
Weblogic uses the NetworkInterface.getNetworkInterfaces() method and his own logic to set the order of the listen addresses. This logic is changed from 10.3.2 to 10.3.4.
The relevant code is in the method getAllAddresses of the class weblogic.server.channels.AddressUtils$AddressMaker in weblogic.jar
You can check the order with a simple test:
import java.net.*;
import weblogic.server.channels.*;
public class TestIP_WLS {
public static void main(String args[]) throws UnknownHostException {
System.out.println("=== AddressUtils.getIPAny()");
InetAddress addrs[] = AddressUtils.getIPAny();
for (InetAddress addr : addrs) {
System.out.println("*** " + addr);
}
}
}