Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Script to display source IP address for home lab

    Hello everyone

    I was hoping someone much smarter than me could help me out. Admittedly I am a complete noobie at Linux and would like some help.

    The story unfolds thus...

    I am setting up a home F5 load balancing lab using the virtual editions, VMware player and Apache running on Ubuntu to simulate my back end servers to which I load balance inbound traffic.

    What I would like to do is this: when I browse to the F5's virtual IP and it then load balances that connection to one of the 3 web servers I have, rather than just displaying any string of text that happens to live on the page I've browsed to, I'd like it to display something like:

    "Your source IP address is <source IP>"
    "Your destination IP address is <destination IP>"

    Why? I hear you asking. Well, it's really just so that as I begin to learn the ins and outs of the F5 platform, I'd like to be able to track my sessions as best as I can, for example, if I did secure NAT or SNAT, then my source IP will be different compared to if I wasn't doing it. By having a nice handy script to do the above it'll basically save me time and really help in my learning experience.

    Is this something that can be done in Linux? In fact, as I write this I realise that actually the best place to post something like this would be on a forum that deals with all things HTTP. But since I'm here, I thought I'd go ahead and ask anyway. Please feel free to tell me to bugger off.

    Again, many thanks for your help and advice.

    Best regards


  2. #2
    Linux Guru
    Join Date
    Dec 2013
    Victoria, B.C. Canada
    It is doable. How it is done will depend on how you're creating the page. Both CGI and SSI provide environment variables that include the remote host. The programming language used will determine how you access this information.

  3. #3
    Hello gregm

    Thanks for your quick response.

    How I am creating the page you ask? Well, as far as I am aware it is as simple as it gets. Just one HTTP page, nothing dynamic. The page simply says "Server 1" on it.

    I am not familiar with CGI & SSI so would need to some guidance here. Without wishing to sound too ungrateful I really just want the simplest way of doing this. Any help and/or advice to that end would be most appreciated.


  4. $spacer_open
  5. #4
    Linux Guru
    Join Date
    Dec 2013
    Victoria, B.C. Canada
    From a simplicity point of view this might be your best bet: Apache Tutorial: Introduction to Server Side Includes - Apache HTTP Server

  6. #5
    Hi gregm

    Yes, I think SSI's are just the ticket. I'll have a read up on that link you sent me.

    Many thanks for your advice.

  7. #6
    Linux User
    Join Date
    Jun 2012
    SF Bay area
    If you have a cgi directory setup, you can drop this incredibly simple shell script in there and it will give you the info you're looking for.

    echo "Content-type: text/plain"
    echo ""
    echo ""
    uname -a
    echo ""
    echo ""
    I know it looks pointless, but it essentially shows you exactly what the request you presented looked like to the webserver and it shows you all the environment variables passed to the CGI script. So you can debug problems with requests you're sending, and can figure out anything you want about the server the handled the request.

  8. #7
    Hello all

    First off thanks for your suggestions.

    I have had success using SSI. For what I need, they do the job very nicely.

    I followed the instructions from a site I found whilst Googling. I can't post the link here as the rules of this forum state that I need to post 15 or more posts before I can embed URLs. If anyone does need this link please message me. Anyway, the site I found has described exactly how to go about getting SSI installed and running and and now I have everything I need to continue with my studies:

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts