Network Addressing Tools Flashcards
What is the official short description of the socket library ?
low-level networking interface
The socket library is built on what? used in what systems?
What extra does it provide?
the famous C socket library
used in UNIX systems
higher-level interface and provides more convenient tools
The contents of the socket library can be categorized into the following five groups:
Socket Objects
Socket Families
Socket Exceptions
Networking constants
Networking Tools
What does the socket object category define
the socket class alongside various methods that are available for socket objects.
The methods are generic and can be applied to client and server sockets
What does socket families category define?
defines various ways to represent socket addresses on different platforms using various protocols.
What does networking tools category define
a rich list of functions to perform various networking operations
what operations can be found in Networking Tools
Address resolution
Network data representation
Getting values of network configuration parameters
Define a hostname
a label (string) given to a specific device so it can be identified within a network.
Define a domain name
if a device is to be identified on the internet then it has to register the name to ensure that it is unique
machine1.secuirty-lab
machine1 is the hostname
security-lab is domain name
What is a fully qualified domain name?
Domain name that is completely specified, including all levels
mail.psut.edu
mail is hostname
psut is domain name
edu is higher-level internet domain
Every domain name is associated with an IP address
The address resolution happens
through the what protocol?
DNS
Can a specific host have multiple hostnames or domain names mapped to the same IP address
Yes
like a web server having an old and a new domain name.
one is considered the hostname and the others are aliases
How to get the local hostname
socket.gethostname()
returns a string representing the hostname (not fully qualified domain name)
How to get hostname on windows cmd
hostname
How to resolve a hostname into an IP address
socket.gethostbyname(hostname)
it returns a four-dot string representing the IPv4 address of the given hostname
if hostname is ‘localhost’ it returns 127.0.0.1 (the loopback IP) special IP address that always points to your own machine.
Does gethostbyname method work for IPv4 and IPv6?
nope only ipv4
In Windows cmd, you can resolve a hostname into an IPv4 address using:
ping -4 <hostname></hostname>
nslookup <hostname></hostname>
It is common to have multiple IPs mapped with a hostname
how to get all of them?
socket.gethostbyname_ex(hostname)
returns a tuple (p_hostname, aliaslist, iplist)
does gethostbyname_ex support both ipv4 and ipv6
nope only ipv4
what command to run on cmd to get all the IPs ??
ipconfig
If I have the IP, how can I resolve it to its hostname
socket.gethostbyaddr(ip_addr)
returns a tuple (p_hostname, aliaslist, iplist)
The output is the same for gethostbyaddr() and gethostbyname_ex()
how can they differ
gethostbyaddr() supports both ipv4 and ipv6
gethostbyname() only supports ipv4
You can perform reverse DNS through Windows cmd using
nslookup ip