EzDevInfo.com

hostname interview questions

Top hostname frequently asked interview questions

How to get full host name + port number in Application_Start of Global.aspx?

I tried

Uri uri = HttpContext.Current.Request.Url;
String host = uri.Scheme + Uri.SchemeDelimiter + uri.Host + ":" + uri.Port;

and it worked well on my local machine, but when being published to IIS7, there is an exception saying

System.Web.HttpException: Request is not available in this context

Anyone know how to achieve this?


Source: (StackOverflow)

Host Name Vs Canonical Host Name

Can anyone please explain me the difference between Host Name and Canonical Host Name?

I am currently using InetAddress class to fetch host name using the IP Address. I came across these 2 APIs. So I am just wondering, which one I should opt for?


Source: (StackOverflow)

Advertisements

Python lookup hostname from IP with 1 second timeout

How can I look up a hostname given an IP address? Furthermore, how can I specify a timeout in case no such reverse DNS entry exists? Trying to keep things as fast as possible. Or is there a better way? Thank you!


Source: (StackOverflow)

How can I get a the host name (with port) that a servlet is at

I thought ServletContext might provide a method. Does the getAttribute() method of ServletContext provide any help i.e. is there an attribute name (maybe "host", "port") that will be of help.

The reason for this is I want my application to run wherever it is deployed, and at one point I have to allow a user to click a link that points to a location on the file server. Hence I need to reference by the host and port and cannot use an internal reference.


Source: (StackOverflow)

Get hostname from Rails controller

I am trying to get the hostname of the machine which a rails application is running on from the controller.

What would be the best way to do this taking into account it should work on both windows and linux?


Source: (StackOverflow)

What is the maximum number of characters for a host-name in Unix?

I am wondering what is the maximum number of characters for a host-name in a Unix system. In addition is there any defined variable that can be used in Unix programming to call that number? (i.e. number of characters allowed for a host-name).

I am programming in C.


Source: (StackOverflow)

Alias hostname for localhost

Assuming that a local Python-Script is running a webserver.

Is there any way to set an alias, so that http://localwebapp/ equals http://localhost:1234/?

Edit: Or at least http://localwebapp:1234/ equals http://localhost:1234/?


Source: (StackOverflow)

What does MySQL "::1" hostname refer to?

On a freshly installed (windows version of) MySQL 5.5.9

SELECT user, host FROM mysql.user

gives:

user            host    

root        localhost   
root        127.0.0.1    
root        ::1  
localhost    

But what IP/hostname does ::1 stand here for?


Source: (StackOverflow)

How to get hostname from IP(Linux)?

I'd like to get remote machine/hostname through IP Address. I found lots of answer such as nslookup, host, resloveip, etc.. but I still can't get hostname from my target machine(cent OS, ubuntu etc...) It seems need to register to DNS server?

I have a machine named test and using IP 10.1.27.97

but I used the method above still can't not get "test"

Does anyone can help me to get the hostname form IP Address?


Source: (StackOverflow)

Get the hostname from a DataSource class

Is there a way to get the hostname from the DataSource class in java? I mean, I have a DataSource object (DS), which is annotated to get the Jboss datasource. Anyway, I want to get the hostname used in that DS.

Debugging, i can see it this way: I get the Connection from DS, then I get the DataSourceMetaData and inside of that the is something called Protocol Connection which have the hostname, but I don't know how to get it.

Anyone here knows how? or another way to get the hostname? Thanks in advance. Kind regards, RDAM


Source: (StackOverflow)

Setting the Hostname in IIS Bindings Breaks Website

I just got a Windows Server 2008 VPS and I'm having trouble getting IIS7 setup.

I created a new website in IIS with the path, ip address, and hostname (like 'www.nameofsite.com') and click OK. When I browse to the site it pulls up "http://www.nameofsite.com" in the browser and... nothing... IE cannot display this webpage.

If I blank out the hostname in the bindings and click [Browse] it works fine (it takes me to http://10.10.2.92 - the computer's ip). So entering the hostname breaks the website.

Any ideas on what I'm missing? Services I might not have running or roles I'm missing?

No server roles were initially installed on the VPS so I installed IIS, DHCP, DNS, and Application Server... overkill, but I wasn't sure what to install.


Source: (StackOverflow)

How do I get the local hostname if unresolvable through DNS in Java?

This sounds like something that should have been asked before, and it has sort of, but I'm looking to get the local hostname and IP addresses of a machine even when it is not resolvable through DNS (in Java).

I can get the local IP addresses without resolution by iterating through NetworkInterfaces.getNetworkInterfaces().

Any answers to this question I've found indicate to use getLocalHost()

InetAddress localhost = java.net.InetAddress.getLocalHost();
hostName = localhost.getHostName();

but this throws an UnknownHostException if the hostname isn't resolvable through DNS.

Is there no way to get the local hostname without a DNS lookup happening behind the scenes?

edit: the IP address retrieved is 10.4.168.23 The exception is java.net.UnknownHostException: cms1.companyname.com: cms1.companyname.com (hostname changed for pseudo-anonymity), and the hosts file does not contain the hostname. But it does know its hostname, so I'm not sure why I can't get it without an exception being thrown.


Source: (StackOverflow)

IP Address to Hostname in Java?

My hosts file (C:\WINDOWS\system32\drivers\etc\hosts) has a bunch of IP Address to host name mappings:

# Switches
192.168.200.254       sw-con-ctrl
192.168.201.253    sw-con-ctrl-2
192.168.201.254       sw-con-ctrl-1
# 192.168.188.1       sw-con-ctrl-blk-1
# 192.168.189.1       sw-con-ctrl-red
192.168.190.62        access-console

# Routers
192.168.21.1          rtr1
192.168.22.1          rtr2

I am trying to find a way to convert from an IPAddress to the HostName programmatically through Java APIs.

Pseudocode:

IPAddress ip = new IPAddress("192.168.190.62");
String host = ip.getHost();
System.out.println(host);  //prints "access-console"

Source: (StackOverflow)

Running IIS Express with admin privilages

This has been asked before but was closed as "Not a real question"

How to run a site with administrative privileges in IIS express 7.5

However I think it is a genuine question as I also need to do this, there are MS documents explaining how to "Run IIS Express without Administrative Privileges" but as this is how it runs by default the need for this article quite frankly baffles me. However I have no idea on how to run it with Admin privileges.

When I try to start my VS2012 website I get the following error message from IIS express: "Cannot start the website because administrative privileges are required to bind to the hostname or port", and links are provided to the MS documents about running it without admin privileges.

What I'm ultimately trying to do is run my dev sites locally as http ://vs2012:nnnnn, this is so I can attach fiddler debugger (due to the bypass of proxies in IE when localhost is used)

This used to work fine, this morning I did a reinstall of windows and have now hit a brick wall!

Does anyone know how to give IIS express admin privileges as indicated in the error message?


Source: (StackOverflow)

rspec route testing and hosts

I see I can test routes with rspec like this:

get("/").should route_to("welcome#index")

but I have constraints based on the hostname or parts of hostnames and redirects between several ones. How do I specify a hostname when testing?

How do I run the tests with proper configuration? I tried printing root_url and I got:

Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true


Source: (StackOverflow)