Instead of IP Address use Hostname in IIS 7 - asp.net-mvc-3

I have a simple project in asp.net mvc3 I publish in my local PC and using my IP Address to open it. I try to use the hostname that I set in the IIS but it will not open the project. How to use hostname in IIS7?. Anyone knows?.

To add a hostname in IIS7 follow this procedure from Microsoft:
Open IIS Manager. For information about opening IIS Manager, see
Open IIS Manager (IIS 7).
In the Connections pane, expand the Sites
node in the tree, and then select the site for which you want to
configure a host header.
In the Actions pane, click Bindings.
In the
Site Bindings dialog box, select the binding for which you want to
add a host header and then click Edit or click Add to add a new
binding with a host header.
In the Host name box, type a host header
for the site, such as www.contoso.com.
Click OK.
To add an
additional host header, create a new binding with the same IP
address and port, and the new host header. Repeat for each host
header that you want to use this IP address and port.
This configuration means requests received by IIS for this hostname will be sent to the specific site you have configured.
However you need a configuration for requests to actually arrive to this IIS Server and this is where DNS is used.
Your server can be found via its IP(s) address(es). Here you want your server to be found via a hostname, so you need a configuration somewhere which says your hostname points to your server IP.
If this is for an intranet site, ask your network team.
If this is for an internet/extranet website, you need to buy a domain name, and your provider will allow you to make the DNS configuration.
If this is for local (windows) use only, you can bypass DNS by using the hosts file. Check this page for example. The hosts file allows you to tell your local computer to point a hostname to the IP of your choice.

Related

Configure IIS hostname when using DNS

I need to use a host name for my internal tools so I made a request the DNS guy to add the "oneplan.dev.ad.trw.com" in the DNS server configuration.
After received that he did this:
But when I access the "oneplan.dev.ad.trw.com" I get the IIS welcome page:
And if I specify the port: oneplan.dev.ad.trw.com:6202. The page is displayed correctly.
What I need to to in order to make it work without the port in the URL? I can't use the default port 80 because I have multiple application on the same server.
You have two options:
Option 1 - Explicit Host Names
Make sure none of the sites have a wildcard binding on port 80 - ensure they all have a unique Host Name specified. If they look like the following, you must added configure an explicit Host Name (e.g. dev.ad.trw.com or *.dev.ad.trw.com) under bindings:
Once this has been completed, you should be able to change the port of your new site from 6262 to 80 and IIS will route port 80 traffic to the appropriate site based upon Host Name.
Option 2 - Add IP Address to Network Card
In order to host 2 sites on port 80 on the same machine without explicit Host Names as suggested in Option 1, you need a new IP address added to the network interface. I'm not sure what version of windows you're running and whether your server has the windows GUI installed. If it does, just go into the network settings for the card and follow the instructions below. It's a fairly straight forward.
First open the properties for the network connection, highlight the IPv4 option and click properties:
On the properties page write down the IP Address and the Subnet Mask and then click the Advanced button on the bottom right (got cutoff in the screenshot:
On the advanced properties page popup, click Add in the IP address section and enter a new IP address with the same 3 octets, and any number between 20 and 255 for the final octet (eg. 10.27.233.121 based on your screenshot above). For the subnet mask copy the subnet form the other IP address(es) configured on the machine (e.g. 255.255.255.0) and click ok to save the settings...and continue clicking OK until all of the properties dialogs are closed.
Next go into IIS Manager, click on each of the sites on the server and select Bindings from the Actions panel on the right side. Make sure all sites are bound the original 10.27.233.21 IP address like the site in your screenshot. If you see any sites with a wildcard "*" for the IP Address, modify them to the 10.27.233.21 as well. Once that's done, open the site bindings settings for you site (same as your first screenshot) and configure its bindings the new IP address 10.27.233.121 and change port 6202 to port 80.
To test that the configuration is working do the following (do this on the server): (1) launch Notepad with administrate privileges, (2) click open, (3) paste the following path into the "File Name:" textbox C:\Windows\System32\drivers\etc\host, (4) click ok to open the file, (5) hit enter at the bottom of the text file and paste the following - [IP Address][Tab][DNS Name], and (6) save the file:
10.27.233.121 oneplan.dev.ad.trw.com
If the site loads, you're all set. Delete the line we added to the Host file in the last step, and tell you server guy to modify the DNS record for oneplan.dev.ad.trw.com to point to 10.27.233.121.
open c:\windows\system32\drivers\etc\hosts in notepad as administrator, make an entry:
10.27.233.121 oneplan.dev.ad.trw.com
go into a command window (windowskey+R to open run box and enter cmd) and type ipconfig /flushdns
Congrats, you've just overridden the DNS for that domain address and your computer specifically will always point to the new IP that you defined in the hosts file. Remember to clear it out once your domain is done propagating (your dns guy should have put an A record in the DNS handling the server)

Amazon EC2 instance through public ip is not working

The instance is running fine. I am using linux os and apache-tomcat-8.0.33 server. I can access from private ip using putty But when i am trying to access the same through the public ip, it is not accessible. I have seen the security configurations all ports are enabled.
Can anyone help me how to reslove this issue
inbound image
I faced the same issue recently; I was not able to access the website which I hosted on Ec2 server Via public IP.
Check 1:- the First step would check your AWS security group and make sure all the inbound traffic rules are fine.
Check 2:- Windows firewall can also play a role in disallowing the access via public IP. Create a new Rule for allowing access for HTTP and HTTPS ports (80,443).
Steps
a. Go to control panel -->Windows Firewall ---> Advanced Settings.
b. Select the Inbound rules from the left Menu.
c. Select New Rule from the Right panel.
d. Allow access to ports 80 and 443.
In my case, everything worked fine once I created a new rule in windows firewall under Inbound Rules.
You opened your amazon web console
You go to Amazon EC2 Security Groups
You should have a default group for inbound rules (see below)
You click on Modify inbound rules (modifier les règles entrantes in French here)
Once done, you add your public ip with the subnet you want
I've added my IP public address and you should be good.
Regardless of the number of ports open in your security group, if you must access your ec2 instance using it's public IP, over the internet, you must assign an internet gateway (IGW) to the subnet your ec2 instance belongs to
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Internet_Gateway.html
As you mentioned and others answers, you can find the problem by following this steps:
1- Try telnet to your server by public IP address on port 80, if it opens go to the next step, if not open you have two possible issues:
security group (Check your inbound rules)
web server settings (Check your web server settings and find why not listening on port 80)
2- If telnet was working, so you have not the connectivity issue, now track your web server access log by tail command and try open a page by the browser. If you see your request in the access log, but it does not return the correct value you expected, so you should check your web application.if you can't see your request, check your web server settings.

IIS: unable to browse server using host IP address plus Port number different from 80

I have an app running in IIS on port 7000. I am able to browse localhost and localhost:7000 but when i change local host to the ip of the computer, I am only able to browse and not :7000 why is this the case?
I think the solution is here but i cannot figure out how to get to local policies on windows 7 and change the required settings. Below is what i get when i browse with the port.
When i Added my new application using the IIS Manager, I specified the hostname as localhost. All i had to do was to leave it blank. This setting is similar to the default app in IIS running on port 80

WebMatrix Host File

Is there any way to do a redirect to a WebMatrix address like you would using a host file: 127.0.0.1 localwebsite.com.
I can't use computername:2000 in the host obviously, so how can I use my localwebsite.com with WebMatrix/IIS Express?
From Stefan Schackow:
You need to tweak some local machine settings to allow IIS Express to bind to port 80. As long as you can’t use port 80, all of your local Urls will have “:port#” in the Url, which defeats the ability to run arbitrary hostnames against the web server by way of faking out DNS with your local HOSTS file.
I see there is an article on learn.iis.net that explains how to ACL http.sys to allow IIS Express (and other apps) access to port 80: http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/ The section titled “Using a Reserved Port” has the info.
Once you have done that, you should be able to do the usual tricks with the local HOSTS file, as well as configuring websites with specific host headers in IIS Express – and everything should work.
-Stefan

Difference between specifying IP in host file vs using IP directly

Is there any difference between the following when a intranet URL in accessed in IE
Add an entry in drivers/etc/host file for a name and IP
vs
Use IP directly
e.g. it works with the following link if I have a host entry as (XYZ 10.0.10.200)
http://XYZ/SiteDirectory/ABC/Default.aspx
but when I tried to use IP instead of name
http://10.0.10.200/SiteDirectory/ABC/Default.aspx
It gives me 404 not found error
Yes, there's a difference.
The web server is using HTTP/1.1 and "shared virtual hosting". When the client connects it sends an additional Host: header which contains the hostname part of the URL that the user supplied.
The web server looks at the header to find out which virtual host's data to serve.
In this case, the web server is configured to recognise and serve content from the "XYZ" domain, but doesn't know about any domain called 10.0.10.200
Smells like the webserver is using virtual hosts, so that it serves different pages if the client went to "www.foo.com" or "www.bar.com", even though they have the same IP-address.
As far as I can see there should be no difference. With a host name the order is hosts file before DNS so it should be used.
Is there another line in the host file with the same hostname?
What happens when you do a tacert? (trace route)

Resources