Operations 17 min read

How to Configure Linux Network Interfaces and Core System Files

This guide walks through configuring Linux network interfaces, editing essential system files such as /etc/hosts, /etc/hostname, /etc/resolv.conf, installing DNS utilities, and understanding key configuration scripts like /etc/fstab, /etc/rc.local, /etc/profile, as well as reviewing important log files.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Configure Linux Network Interfaces and Core System Files

1. Network Interface Configuration File

<table><tbody><tr><td># cat /etc/sysconfig/network-scripts/ifcfg-ens33</td></tr><tr><td>TYPE="Ethernet"</td></tr><tr><td>PROXY_METHOD="none"</td></tr><tr><td>BROWSER_ONLY="no"</td></tr><tr><td>BOOTPROTO="none"</td></tr><tr><td>DEFROUTE="yes"</td></tr><tr><td>IPV4_FAILURE_FATAL="no"</td></tr><tr><td>IPV6INIT="yes"</td></tr><tr><td>IPV6_AUTOCONF="yes"</td></tr><tr><td>IPV6_DEFROUTE="yes"</td></tr><tr><td>IPV6_FAILURE_FATAL="no"</td></tr><tr><td>IPV6_ADDR_GEN_MODE="stable-privacy"</td></tr><tr><td>NAME="ens33"</td></tr><tr><td>UUID="4cf09cae-5418-44e9-8450-422230bd68fc"</td></tr><tr><td>DEVICE="ens33"</td></tr><tr><td>ONBOOT="yes"</td></tr><tr><td>IPADDR="192.168.52.130"</td></tr><tr><td>PREFIX="24"</td></tr><tr><td>GATEWAY="192.168.52.2"</td></tr><tr><td>DNS1="119.29.29.29"</td></tr></tbody></table>

Explanation of each field: TYPE specifies Ethernet, PROXY_METHOD disables proxy, BROWSER_ONLY disables browser‑only mode, BOOTPROTO disables DHCP, DEFROUTE sets default route, IPV4_FAILURE_FATAL allows IPv4 failures without stopping the system, IPV6INIT enables IPv6, IPV6_AUTOCONF enables automatic IPv6 configuration, IPV6_DEFROUTE sets IPv6 default route, IPV6_FAILURE_FATAL similar for IPv6, IPV6_ADDR_GEN_MODE uses stable‑privacy address generation, NAME and DEVICE name the interface, UUID is the unique identifier, ONBOOT enables the interface at boot, IPADDR, PREFIX, GATEWAY and DNS1 define the static network parameters.

2. /etc/hosts

System file mapping hostnames to IP addresses. The resolver checks this file before performing DNS queries.

<table><tbody><tr><td># cat /etc/hosts</td></tr><tr><td>127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4</td></tr><tr><td>::1         localhost localhost.localdomain localhost6 localhost6.localdomain6</td></tr><tr><td>127.0.0.1   localhost   # maps localhost to the loopback address</td></tr><tr><td>::1         localhost   # maps IPv6 localhost to the loopback address</td></tr></tbody></table>

3. /etc/hostname

Hostname configuration file.

3.1. Three ways to change the hostname

1) Persistent change (effective after reboot):

<table><tbody><tr><td># vim /etc/hostname</td></tr><tr><td>new-hostname</td></tr></table>

2) Temporary change (lost after reboot): # hostname temporary-name 3) Temporary + permanent change using hostnamectl:

# hostnamectl set-hostname new-hostname
# cat /etc/hostname

4. /etc/resolv.conf

Configuration file for DNS resolution. It can be generated by NetworkManager but may be edited manually to set custom nameservers.

<table><tbody><tr><td># cat /etc/resolv.conf</td></tr><tr><td># Generated by NetworkManager</td></tr><tr><td>nameserver 119.29.29.29</td></tr><tr><td>search localdomain</td></tr></tbody></table>

Note: If the network interface config provides DNS, resolv.conf may be overwritten; otherwise, changes to resolv.conf take effect immediately without a reboot.

5. Installing DNS query tools

# yum -y install bind-utils
# nslookup www.baidu.com

Sample output shows the DNS server used and the resolved IP addresses for the queried domain.

6. /etc/fstab

System file defining filesystems to mount at boot, including device, mount point, filesystem type and options.

<table><tbody><tr><td># cat /etc/fstab</td></tr><tr><td>/dev/mapper/centos-root / xfs defaults 0 0</td></tr><tr><td>UUID=dbee441f-bdcd-41db-824c-3f461eb48952 /boot xfs defaults 0 0</td></tr><tr><td>/dev/mapper/centos-swap swap swap defaults 0 0</td></tr></tbody></table>

Explanation of fields: device, mount point, filesystem type (e.g., xfs), and mount options (defaults).

7. /etc/rc.local

Legacy script executed at the end of the boot process on older Linux systems. Modern distributions use systemd unit files instead.

<table><tbody><tr><td># cat /etc/rc.local</td></tr><tr><td>#!/bin/bash</td></tr><tr><td># THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES</td></tr><tr><td># It is highly advisable to create own systemd services or udev rules to run scripts during boot instead of using this file.</td></tr><tr><td># Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure this script will be executed during boot.</td></tr><tr><td>touch /var/lock/subsys/local</td></tr></tbody></table>

8. /etc/profile

System‑wide Bash configuration file loaded for all users at login. It defines environment variables, PATH manipulation, and other global settings.

<table><tbody><tr><td># cat /etc/profile</td></tr><tr><td># System wide environment and startup programs, for login setup</td></tr><tr><td># Functions and aliases go in /etc/bashrc</td></tr><tr><td>pathmunge () { ... }</td></tr><tr><td>if [ -x /usr/bin/id ]; then</td></tr><tr><td>    EUID=`/usr/bin/id -u`</td></tr><tr><td>    UID=`/usr/bin/id -ru`</td></tr><tr><td>    USER=`/usr/bin/id -un`</td></tr><tr><td>    LOGNAME=$USER</td></tr><tr><td>    MAIL="/var/spool/mail/$USER"</td></tr><tr><td>fi</td></tr><tr><td>if [ "$EUID" = "0" ]; then</td></tr><tr><td>    pathmunge /usr/sbin</td></tr><tr><td>    pathmunge /usr/local/sbin</td></tr><tr><td>else</td></tr><tr><td>    pathmunge /usr/local/sbin after</td></tr><tr><td>    pathmunge /usr/sbin after</td></tr><tr><td>fi</td></tr><tr><td>HOSTNAME=`/usr/bin/hostname 2>/dev/null`</td></tr><tr><td>HISTSIZE=1000</td></tr><tr><td>if [ "$HISTCONTROL" = "ignorespace" ]; then</td></tr><tr><td>    export HISTCONTROL=ignoreboth</td></tr><tr><td>else</td></tr><tr><td>    export HISTCONTROL=ignoredups</td></tr><tr><td>fi</td></tr><tr><td>export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL</td></tr><tr><td>if [ $UID -gt 199 ] && [ "$(/usr/bin/id -gn)" = "$(/usr/bin/id -un)" ]; then</td></tr><tr><td>    umask 002</td></tr><tr><td>else</td></tr><tr><td>    umask 022</td></tr><tr><td>fi</td></tr><tr><td>for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do</td></tr><tr><td>    if [ -r "$i" ]; then . "$i"; else . "$i" >/dev/null; fi</td></tr><tr><td>done</td></tr><tr><td>unset i</td></tr><tr><td>unset -f pathmunge</td></tr></tbody></table>

9. /etc/motd

Message of the day displayed upon remote login.

10. /var/log/messages

System log file containing kernel messages, boot information, hardware detection, and other system events.

<table><tbody><tr><td># cat /var/log/messages</td></tr><tr><td>Jan 10 17:26:45 localhost journal: Runtime journal is using 6.0M (max allowed 48.6M, trying to leave 72.9M free of 480.0M available → current limit 48.6M).</td></tr><tr><td>Jan 10 17:26:45 localhost kernel: Initializing cgroup subsys cpuset</td></tr><tr><td>Jan 10 17:26:45 localhost kernel: Initializing cgroup subsys cpu</td></tr><tr><td>Jan 10 17:26:45 localhost kernel: Initializing cgroup subsys cpuacct</td></tr><tr><td>Jan 10 17:26:45 localhost kernel: Linux version 3.10.0-1160.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44)) #1 SMP Mon Oct 19 16:18:59 UTC 2020</td></tr><tr><td>... (additional kernel and system messages) ...</td></tr></tbody></table>

11. /var/log/secure

Security‑related log file recording authentication events, sudo usage, and other security‑relevant actions.

<table><tbody><tr><td># cat /var/log/secure</td></tr><tr><td>Jan 10 17:26:51 localhost polkitd[956]: Loading rules from directory /etc/polkit-1/rules.d.</td></tr><tr><td>Jan 10 17:26:55 localhost sshd[1521]: Server listening on 0.0.0.0 port 22.</td></tr><tr><td>Jan 10 17:28:51 localhost login: pam_unix(login:session): session opened for user root by LOGIN(uid=0).</td></tr><tr><td>Jan 10 18:03:54 localhost polkitd[956]: Registered Authentication Agent for unix-process:1868:222974.</td></tr><tr><td>... (additional security events) ...</td></tr></tbody></table>
Linux configuration illustration
Linux configuration illustration
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxconfiguration files
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.