You can get the advice from IT HELP DESK

SYSTEM [LINUX] How to set up and manage the network

17 Jan 2019
<head>Disk Management, Server Monitoring, System management, server monitoring, server management, system management, system monitoring, </head>

 [LINUX] How to set up and manage the network

Hello ~!

I will explain how to set up and manage the network ~

Let's look at how to set up network information and run network daemons on Linux OS.

1. /etc/sysconfig/network

The file /etc/sysconfig/network is a file that contains settings for the entire Linux system. In general, the items set in the network file are as follows.

  • Network availability
  • Hostname
  • Gateway IP address
  • Interface name to communicate with Gateway

[root@localhost sysconfig]# vi /etc/sysconfig/network


The hostname is localhost  and the gateway is "

After you change the file, you must reboot the network via the service network restart  command before the changes take effect. 

2. /etc/hosts 

The /etc/hosts file is simply a file that names the IP address.

Most of them are using DNS servers nowadays but they are still useful in networks without a separate name server!

[root@localhost sysconfig]# vi /etc/hosts         localhost
::1                   localhost    backupSVR

As an example, suppose that the above sample is recorded in the /etc/hosts file

I will connect to the backupSVR host on my Linux machine! It is automatically connected to

3. /etc/resolv.conf 

The /etc/resolv.conf file specifies the IP address of the DNS server.

I explained that I will write IP through /etc/hosts file. But how do I import a domain that is not in the /etc/hosts file?

In general, the procedure for searching for IP in Linux is as follows.

  1. View local cache data
  2. View the /etc/hosts file
  3. DNS lookup

At this time, in order to find a hostname that is not in the /etc/hosts file, the DNS server will ask for the IP address of the hostname

The file that can specify this DNS server is the /etc/resolv.conf file!

[root@localhost sysconfig]# vi /etc/resolv.conf


In the above example file, you can see that / two DNS servers are specified.

These two IPs are Google's Public DNS (IPv4) IP addresses.

If you have a DNS server that you use separately, you can do the same.

If the contents change, the network must be restarted via service network restart  command before the changes take effect.  

4. /etc/sysconfig/network-scripts/ifcfg-eth0

The files described above are network settings that are commonly used by the OS.

This file is a file that can assign a name to each network interface, assign an IP, and apply various settings.

The default gateway and other settings above may overlap with the values set in this file,

Please note that in this case, the data recorded in this file take precedence!

[root@localhost sysconfig]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DNS1 =

The above configuration file is the contents of the ifcfg-eth0 file with the IP address assigned to the eth0 interface, the gateway, and the DNS server

Let's take a look at what each line means.

[root @ localhost sysconfig] #  vi /etc/sysconfig/network-scripts/ifcfg-eth0 

## Name of the network interface
 DEVICE = eth0

## Ethernet / bond / Tap is set as the type of network interface. ## Under normal network settings, Ethernet is the default. 

TYPE = Ethernet

## Unique ID of interface

## Enable or disable the interface automatically when booting OS
 ONBOOT = yes

## Allow network setting in GUI mode

## Set the IP grant method. When static IP is set, static
 BOOTPROTO = static

## Specify the IP address of the network interface

## Specify the subnet mask for the network interface

## Specify the gateway address to which the network interface will communicate

## Specify the DNS address to which the network interface will communicate
 DNS1 =

## Whether ordinary users can control their network interfaces

## Whether to use your own DNS. When set to yes, DNS server configuration is required in /etc/resolv.conf
 PEERDNS = yes

## Enable IPv6?
 IPV6INIT = no

## MAC address of the Ethernet card

5. Run the network daemon 

Unlike Windows, changing network-related settings on Linux does not take effect immediately.

After you make the changes, the changed values will not take effect until you rerun the network daemon.

  •    Network service program: /etc/init.d/network 
    • Run the network service program: /etc/init.d/network.start   
    • Restart the network service program: /etc/init.d/network.restart     
    • Exit the network service program: /etc/init.d/network.stop 

The above command is executed through the network executable file in /etc/init.d

Normally, network binaries are registered with the service.

  • service network start / restart / stop

It can be used in the above form.

Please leave a comment on the question.