Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The third script is get_external_ip.sh, whose purpose is to find the public/exte

ID: 3669011 • Letter: T

Question

The third script is get_external_ip.sh, whose purpose is to find the public/external IP address that you are currently using to connect to the Internet. The IP address assigned to your laptop is almost certainly a private address, i.e., one that can't be used to communicate with other computers outside of your LAN. When your packets leave the LAN, a Network Address Translation device rewrites parts of your packets so that they get one of the public IP addresses that are available for your LAN. There are many websites that will tell your current public IP address, so we will use one of them to do this. Let's see that first:

Open up your web browser and go to: www.ipchicken.com

The web page will tell you your current public IP address.

Of course, web pages are just plain text HTML documents, and so we can write a script that downloads the web page and pulls out the IP address using a regex. There are many ways to think about the regular expression, but by far the simplest is to only match strings that look like IP addresses. To get started, use wget to download the webpage to a local file. Look through the file to find the IP address inside. Then use grep to search through the file for strings that look like IP addresses and only print those out. Of course, grep will print out the entire line that matches, but there is an option to grep that will have it only print out the actual matching string so you'll want to find that. Then, remove the downloaded file to clean up after yourself. Once you get the steps correct by hand, you can put them into the script which should be three lines long. Here is a sample run:

[user@localhost lab3]$ ./get_external_ip.sh

108.7.215.94

[user@localhost lab3]$

Once you've got it tested and working, TAKE SCREENSHOT 3 of the output of the script for a sample run. Only provide a single screenshot. More than one will be ignored. PLACE SCREENSHOT 3 HERE:

Explanation / Answer

wget http://www.ipchicken.com/

egrep '<[[:digit:]]{1,3}.[[:digit:]]{1,3}.[[:digit:]]{1,3}.[[:digit:]]{1,3}>' index.html

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote