Tracking where incoming browser visits come from is part of determining the effectiveness of your business's web presence. IP addresses can be tracked back to their country of origin for traffic analysis purposes. They can also be used as the basis for policy administration, such as blocking spammers from comment sections on your company's blog or web-shop. The netstats command is common to both Linux/Unix and Windows servers, and provides current information about incoming IP addresses. In addition to netstats, it is also possible to use function calls in a scripting language to show an incoming IP address on a web page.
From The Console/Command Line
Video of the Day
Step 1
Launch a terminal window (Linux) or a command prompt window (Windows).
Video of the Day
Step 2
Enter the following command: "netstat –f." This will give you a table that shows all of the computers connected to yours via TCP/IP. The "-f" command will also display their full domain names. This works identically on Windows and Linux.
Step 3
Enter the following command: "netstat –f > test_log.txt." This will take the data shown in the previous command and write it to a text file called test_log.txt. This works identically on Windows and Linux.
Within A Web Page
Step 1
Open your HTML file in your text editor, and choose the place you want to display the incoming IP address on the page. Depending on the scripting language you use in your web and server environment, use one of the following.
Step 2
Resolve the incoming IP address in PHP with the $_SERVER array call. The format would be:
Step 3
Resolve the incoming IP address in ASP by requesting the REMOTE_ADDR server variable. The format would be: <%=Request.ServerVariables("REMOTE_ADDR")%>
Step 4
Resolve the incoming IP address in .NET via the UserHostAddress property. The format would be: <%= Request.UserHostAddress%>