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

Your project is to write a Python program that records your computer\'s local an

ID: 3919702 • Letter: Y

Question

Your project is to write a Python program that records your computer's local and global IP addresses to a public website. Python can be installed on almost any operating system. The code you write for this project should run successfully on Windows and Linux Your program should 1. Get the IP address of the computer where the program runs. This should not be a localhost address 2. Use [1] below, or substitute another service, to retrieve your global IP address (sometimes called public address) 3. Record both addresses to a public web service such as [2] below. Any service where you can post text using an API and later retrieve it is fine. 4. In your recorded text, identify which IP address is the local address and which is the global address 5. Output a URL to the recorded data that can be used to see it in a web browser. Questions you should be able to answer after completing this project: 6. Are the addresses you recorded IPv4 or IPv6? How can you tell? 7. You used a web service to get your global address. Why do you have to ask someone else to find out what your global address is? 8. Run the program on your computer. Are the local and global addresses the same or different addresses? Why? 9. If possible, run the program on another computer on the same network. Are the addresses the same as on your first computer? Why? 10. Run the program on one of the CS workstations or serves, [3] below. Are the local and global addresses the same or different? [1] https://www.ipify.orgl [2] https:/lpastebin.com/

Explanation / Answer

Program :

import socket

from requests import get, post

localIP = socket.gethostbyname(socket.gethostname())

publicIP = get('https://api.ipify.org').text

url = 'http://pastebin.com/api/api_post.php'

data = {

'api_dev_key': '<Your Pastebin API dev key>',#Please fill the key here

'api_option': 'paste',

'api_paste_code': 'localIP = ' + localIP + " publicIP = " + publicIP

}

r = post(url, data)

print(r.text)

Questions :

6.) IPv4 addresses are 32-bit long with decimal numbers separated by a dot and IPv6 addresses are 128 bit long with hexa-decimal numbers separated by colon. Hence the ones obtained above are IPv4 addresses.

7.) Public IP is the address that is assigned by the ISP and which determines the area where a packet should receive. Hence it is known to web services across the internet and not known to local computer.

8.) Local and global address are different on the same computer. Global address is used to identify computers in a network and local address is used to identify the exact receiver in that network. For example, global address is like your home address where a postman would arrive. He leaves the letter in the mailbox. Now among all the people living in your apartment, you pickup that letter because it has your name on it. Similarly ISP isn't able to provide each machine a separate global address. So it provides on global address to a network, which multiple devices can share because they would have different local addresses. A local address of a device in one network might be equal to local address of device in some other network. Global address is however always unique.

9.) Another computer in the same network would have same global address but different local addresses.

10.) Because a CS workstation or server would be in a different network, it would have different global address.