Skip to content

IPs & Interfaces

Before configuring anything, you need to know the name of your network card (e.g., enp0s3).

  • Quick Check: ls /sys/class/net.
  • The “Standard” Way: ip addr (or ip a).
  • Detailed Hardware Info: sudo lshw -class network.
  • Legacy/Old Way: ifconfig.

The ip utility is used for immediate, temporary changes that disappear after a reboot.

ip [options] object command [parameters]

  • Objects: address (or a), link (or l), route (or r).
  • Common Options:
    • br (Brief): Summary for readability.
    • 4 / 6: Show only IPv4 or IPv6.
    • s (Stats): Show traffic statistics.
  • Add IP: sudo ip addr add 192.168.1.200/24 dev enp0s3.
  • Bring Interface Up/Down: ip link set dev enp0s3 up (or down).
  • Set Gateway: sudo ip route add default via 10.1.1.1.
  • Clear All IPs: ip addr flush enp0s3.

To make changes survive a reboot, you must edit configuration files.

Uses YAML files in /etc/netplan/*.yaml.

Warning: No tabs allowed! Use only spaces.

  • To Apply: sudo netplan apply.
  • To Test: netplan try (reverts if you lose connection).

NOTE: An Interface can have multiple address

image.png

Uses text files in /etc/sysconfig/network-scripts/ifcfg-[interface].

  • To Apply: systemctl restart network (Note: Modern CentOS/RHEL 9 uses nmcli instead).

  • Key File Settings:

    • BOOTPROTO="none" (for Static) or "dhcp".
    • ONBOOT="yes" (starts on boot).
    • NOTE: network and above script config is Depricated in new versions of RedHat.. its moved to /etc/NetworkManager/system-connections

    Best for servers and scripts. It controls the NetworkManager service directly.

    • Show status: nmcli device or nmcli connection show.
    • Modify connection: nmcli con mod [name] +ipv4.addr "10.0.5.20/24".
    • Activate changes: nmcli con up [name].

    image.png

    image.png

    image.png

    image.png

    • nmcli con mod <CON_NAME> +/- ipv4.addr “IP ADDR”
    • nmcli con up/down <CON_NAME>

    image.png

    OLD stuff can be managed by ifcfg from sudo dnf install network-scripts -y

    image.png



  • Hostname: Use hostnamectl set-hostname [name].
  • DNS (Manual/Temporary): Edit /etc/resolv.conf and add nameserver 8.8.8.8.
  • DNS (Ubuntu/Modern): Configured via the nameservers section in your Netplan YAML.
  • Troubleshooting: systemd-resolve --status shows current active DNS servers.
  • For flushing DNS cash may be used command: systemd-resolve --flush-caches
  • For setting DNS server address may be used command: systemd-resolve --set-dns=SERVER

image.png

  • /etc/resolv.conf: This is the legacy standard. Almost every Linux application is hard-coded to look at this specific file to find its DNS instructions.
  • /run/systemd/resolve/resolv.conf: This is the modern dynamic file. It is generated automatically by the systemd-resolved service and contains the “real” DNS servers your network is currently using.

image.png

Featureip Commandnmcli (NetworkManager)
PersistenceTemporary. Changes take effect immediately but are lost after a reboot.+1Permanent. Changes are saved to configuration files and survive a reboot.+1
Object TypeWorks with low-level system objects like address, link, and route.+2Works with high-level connections and devices.+1
UsageIdeal for quick testing or one-time troubleshooting.Ideal for servers and persistent network setups.+1
Syntaxip [options] object command [parameters].`nmcli [options] OBJECT { COMMAND

image.png

image.png

  • lshw → for in-depth details

    image.png

    image.png

  • to change any of the above details… we can use ethtool

    image.png

    image.png

  • sudo hostname <NEW NAME> OR hostname

image.png

image.png

image.png

image.png

image.png

image.png

image.png