Added code and output for C10. Added links for those in README.

This commit is contained in:
K 2024-10-08 23:54:54 +05:30
parent 84fe0dd4ae
commit 5d16890980
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F
3 changed files with 28 additions and 0 deletions

26
Codes/Code-C10.py Normal file
View File

@ -0,0 +1,26 @@
import socket
def dns_lookup():
choice = input("Choose an operation:\n1 -> lookup a URL\n2 -> lookup an IP address\nEnter choice (1/2):\t")
if choice == '1':
url = input("Enter the URL (e.g. kska.io): ")
try:
ip_address = socket.gethostbyname(url)
print(f"The IP address for {url} is: {ip_address}")
except socket.gaierror:
print("Error: Unable to resolve the URL.")
elif choice == '2':
ip_address = input("Enter the IP address (e.g. 93.184.216.34): ")
try:
url = socket.gethostbyaddr(ip_address)[0]
print(f"The URL for {ip_address} is: {url}")
except socket.herror:
print("Error: Unable to resolve the IP address.")
else:
print("Invalid choice. Please enter 1 or 2.")
if __name__ == "__main__":
dns_lookup()

Binary file not shown.

View File

@ -69,7 +69,9 @@ This Git repository is a comprehensive resource for the Computer Networks and Se
- [Output-B9](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Printable%20outputs/Output-B9.pdf)
##### C10 - DNS
- [Code-C10](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Codes/Code-C10.py)
- [Handout-C10](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Handouts/Handout-C10.pdf)
- [Output-C10](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Printable%20outputs/Output-C10.pdf)
##### C11 - DHCP
- [Handout-C11](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Handouts/Handout-C11.pdf)