Networking on Linux Platform - Week #1 Notes
Lesson Overview
- Network Services:
- Understanding related files and settings.
- Static and dynamic IP configuration.
- Hostname resolution (both static and dynamic).
- Overview of network management tools.
- Device management and common network errors.
Service Management
- Network Service Management: Utilize
systemctl for service management:- Commands include:
status, start, stop, restart, reload, enable, disable.
- NetworkManager:
- Manage individual interfaces with commands:
nmcli connection up (to activate a connection).nmcli connection down (to deactivate a connection).ip link set <interface> up (to set an interface up).
- Network Configuration: Source scripts setup networking from:
/etc/sysconfig/network-scripts//etc/NetworkManager/system-connections/
Interface Configuration
- Interface Configuration Files:
- Each interface has its own configuration file at
/etc/sysconfig/network-scripts/ifcfg-interface.
- Configuration Options:
- Includes static and dynamic settings:
- Static Configuration: Manually supplied IP parameters.
- Dynamic Configuration: IP parameters supplied by DHCP.
Example: Dynamic IP Configuration
- Configuration file example for dynamic IP:
DEVICE=ens160
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
PEERDNS=yes
DEFROUTE=yes
Example: Static IP Configuration
- Configuration file example for static IP:
DEVICE=ens224
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.16.30.167
NETMASK=255.255.0.0
NETWORK=172.16.0.0
#GATEWAY=172.16.30.1 #Optional Gateway
Assigned Hostname
- Hostnames:
- Static Hostname: A hostname assigned manually.
- Transient Hostname: Reflects the current network configuration (e.g., provided by DHCP).
- Hostname Management:
- Set a static hostname:
- Command:
hostnamectl set-hostname moe000-srv.example167.lab - Recorded in
/etc/hostname. - View the hostname with
hostnamectl.
Hostname Resolution
- Definition of Hostname Resolution:
- Process by which a Fully Qualified Domain Name (FQDN) resolves to an IP address.
- Static vs Dynamic Resolution:
- Static resolution managed via
/etc/hosts: - Contains localhost entry and server name entry.
- Dynamic resolution managed via
/etc/resolv.conf: - Contains a list of name servers.
- Configuration Example for Static and Dynamic Resolution:
- Static
/etc/hosts:
127.0.0.1 localhost.localdomain localhost
172.16.30.167 moe000-srv.example167.lab
- Dynamic
/etc/resolv.conf:
search <list of default domain names>
nameserver <IP of DNS server>
nameserver <IP of another DNS server>
Default Gateway
- Default Gateway:
- Entry for all traffic not destined for the local network.
- Can be configured via DHCP or statically.
- To view routing table:
ip route (displays default via <IP>, dev <interface>).
Verifying Network Setup
- Device Setup Commands:
- Use
ip link instead of ifconfig. - View hardware with
lspci -v.
- IP Configuration Commands:
- Use
ip addr (replaces ifconfig). - Use
ip route (replaces route). - Use
ping <IP> to check connectivity.
- Hostname Setting/Resolution:
- Check with
hostnamectl, getent hosts, and ping <hostname>.
Common Causes of Network Issues
- Possible issues to check:
- Network cables unplugged or faulty.
- Interface disabled or not properly configured in VMware.
- Wrong network service or DHCP client not started.
- Incomplete routing table, multiple default gateways, or hostname resolutions issues (static/dynamic).