Added code and output for C10. Added links for those in README.
This commit is contained in:
parent
84fe0dd4ae
commit
5d16890980
26
Codes/Code-C10.py
Normal file
26
Codes/Code-C10.py
Normal 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()
|
BIN
Printable outputs/Output-C10.pdf
Normal file
BIN
Printable outputs/Output-C10.pdf
Normal file
Binary file not shown.
@ -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)
|
- [Output-B9](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Printable%20outputs/Output-B9.pdf)
|
||||||
|
|
||||||
##### C10 - DNS
|
##### 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)
|
- [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
|
##### C11 - DHCP
|
||||||
- [Handout-C11](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Handouts/Handout-C11.pdf)
|
- [Handout-C11](https://git.kska.io/sppu-te-comp-content/ComputerNetworksAndSecurity/src/branch/main/Handouts/Handout-C11.pdf)
|
||||||
|
Loading…
Reference in New Issue
Block a user