
Linux Network Interfaces
- Loopback – Represents host itself and have an IP address of 127.0.0.1
- Ethernet – The ethernet 0 (eth0) interface connects to the physical network interface of the host.
A network interface assigned with a unique identifier, i.e., media access control (MAC) address at the Data Link layer (layer 2) of the OSI Model referred to as the hardware address at the time of network adaptor manufacturing. It appears as six groups of two hexadecimal digits each.
A unique IP Address between 1.1.1.1 and 255.255.255.255 is provided to each device, tied to the MAC address of the network adapter.
- Static IP: The administrators manually configure IP, which remains the same every time network adaptor starts.
- Dynamic IP: The dynamic host configuration protocol (DHCP) automatically obtain an IP address when a host or device comes on the network. When the computer starts, DHCP sends the request on the network. The DHCP server responds to it with the IP address configuration (IP address, subnet mask, default gateway,and DNS server details) for that device and gets reserved so that accidentally does not get assigned to some other device.
/etc/dhcp/dhclient.conf
It is the local configuration file for the DHCP client called dhclient. It dictates OS how it will receive IP configuration information from a DHCP server.
sudo grep -Ei dhcp /var/log/syslog
syslog – system log file
The TCP/IP protocol connects computers with each other using IP addresses. It's logically impossible to remember IP addresses. Therefore, DNS (Domain Name System) ease the things by mapping IP addresses to names by doing a DNS lookup.
etc/hosts
file contained the host-names and checked first.
/etc/resolv.conf
shows the local domains to be searched and what server names to use for DNS resolution.
hostname: List the system's hostname
ip link ip -s link ip link set [dev] { up | down } ip link set lo mtu 1500
Configure network interfaces/ devices/ links. The command without options shows different interfaces, their status, and their MAC addresses
ip address ip addr: Display IP address information for each interface
ip route: Display local routing table
ifup [interface-name]: Brings an interface up
ifdown [interface-name]: Brings an interface down
service network status: Display currently active interfaces
service network stop: Disable networking
service network start: Enable networking
service network restart: Restart Networking
netstat: Displays active processes that have active network interface connections
netstat -l: Shows us the active listening services on this host
ping: For testing network reachability. It sends out an Internet Control Message Protocol (ICMP) packet across the network and notifies whether there is a response. If a host is not reachable, a notice of unreachable or timed out response is received, which means that the ping test failed
traceroute: It probes the network between the local system and a destination, gathering information about each IP router in the path. The administrators use it to detect network issues like host down or slow responses at intermediary nodes
dig: The domain Internet groper, or dig, performs verbose DNS lookups
getent ahosts: Enumerates name service switch files, specifically for host entries
nslookup: It performs a variety of different DNS server lookups: mail server lookups, reverse lookups, and more and used to look up the IP address of a host.
>> Next Page: Network Interfaces and Routes