VanDyke Software

Tips

Index

This tip explains how to assign local IP addresses to connections and map names to these connections using the Windows HOSTS file.

Note: This tip is for use with SecureCRT® for Windows®.

Setting Up Remote Server Connections Using Local IP Addresses

Do you use SecureCRT port forwarding to connect to multiple web servers on different networks? This tip for more advanced users shows you a way to manage connections with localhost addresses and the Windows HOSTS file. It assumes a basic knowledge of TCP/IP and Secure Shell port forwarding.

A port forwarding user struggled with how to meet the requirement that each web server use port 80. He had been identifying servers by assigning them different port numbers, but found that some servers did not work properly. He also ended up with a list of URLs that weren't easily identifiable when he wanted to find a particular server in the "Connect" dialog:

    http://localhost:80
    http://localhost:8000
    http://localhost:8001
    http://localhost:8002


It would be more intuitive to access a given port forward using a name that could be easily identified, such as http://mysite/.

Two steps are required to do this. First, rather than using the same localhost ID (127.0.0.1) for each connection and then giving each connection a separate port number, you can assign any local IP address (127.x.y.z) to a connection.

For example:

    http://127.0.0.1:80
    http://127.0.0.2:80
    http://127.0.0.3:80

This allows you to use the proper port and assign different IP address for each site.

A quick explanation of local IP addresses: In IP addressing, the network address with the initial number "127", like those shown above, is reserved for internal functions. You may also hear it called the "loopback address". "Localhost" is an alias or placeholder name for the current machine on which a program is running.

Once you have set up the correct local IP addresses, you can use a Windows HOSTS file to associate a hostname with any IP address. In Windows XP, the HOSTS file is located in the directory c:\windows\system32\drivers\etc\hosts, and contains IP addresses, domain names, and comments. Your sample entries would look like this:

    127.0.0.1         news         # News server
    127.0.0.2         dev          # Development web server
    127.0.0.3         corp         # Corporate web server

Once this is done, you can use the hostname when setting up port forwarding in SecureCRT instead of having to remember IP addresses. Then, the servers would appear in the "Connect" dialog something like this:

http://news
http://dev
http://corp

The HOSTS file usually takes precedence over other services such as DNS (Domain Name System). Be aware that in certain complex environments, setting this up may require the assistance of a system administrator.

For basic information on TCP/IP networking, one valuable resource is "TCP/IP For Dummies, 6th Edition", by Candace Leiden et. al. ISBN: 978-0-470-45060-4.

  http://www.dummies.com/store/product/TCP-IP-For-Dummies-6th-Edition.productCd-0470450606.html

Note: If you use Windows XP Service Pack 2 (SP2), using this technique may result in the connection hanging, and then timing out. Windows XP SP2 introduced a change in behavior that resulted in the inability to bind to any loopback address other than 127.0.0.1. You can read the Microsoft article, "Programs that connect to IP addresses that are in the loopback address range may not work as you expect in Windows XP Service Pack 2," and download a fix on the Microsoft web site.