RedHat Linux network configuration (directly modify the configuration file instead of setup)

Source: Internet
Author: User
Tags domain name server nameserver

RedHat Linux network configuration (directly modify the configuration file instead of setup)



To create a Linux server, you must first understand the meaning of the configuration files related to network services in the Linux environment and how to configure security. In Linux, the TCP/IP network is configured through several text files. You may need to edit these files to complete networking, the following describes several basic TCP/IP network configuration files.

1./etc/sysconfig/network-scripts/ifcfg-<interface-Name> File

In RedHat, the configuration file for the system network device is saved in the/etc/sysconfig/network-scripts directory, the ifcfg-eth0 contains the configuration information for the first Nic, the ifcfg-eth1 contains the configuration information for the second Nic. At startup, the system reads the configuration file to determine whether or not a NIC is started and how to configure it.

The following is an example of the/etc/sysconfig/network-scripts/ifcfg-eth0 file:

Device = eth0

Ipaddr = 192.168.0.2

Netmask = 255.255.255.0

Broadcast = 192.168.0.255

Onboot = Yes

Bootproto = none

Gateway = 192.168.0.1


If you want to manually modify the network address or add a new network connection, you can modify the corresponding file ifcfg-<interface-Name> or create a new file.

Device = <Name> indicates the name of the physical device.

Ipaddr = <address> indicates the IP address assigned to the NIC.

Netmask = <mask> indicates the subnet mask.

Broadcast = <address> indicates the broadcast address.

Onboot = yes/no whether the card is activated at startup

Bootproto = none: no startup protocol required

BOOTP: Use the BOOTP protocol

DHCP: Use the DHCP protocol.

Gateway = <address> indicates the default gateway.

Macaddr = <Mac-address> specifies a MAC address.

Userctl = yes/no whether non-root users are allowed to control the device


2./etc/resolv. conf file

File/etc/resolv. conf to configure the DNS client. It contains the DNS server address and domain name search configuration. Each line should contain one keyword and one or more parameters separated by spaces. The following is an example file:

Search wuxp.com

Nameserver 192.168.0.1

Nameserver 192.168.0.2


Search wuxp.com: when a host name that does not include a full domain name is provided, add the suffix wuxp.com after the host name; nameserver: indicates that the host specified by this address is the Domain Name Server when the domain name is resolved. The Domain Name Server is queried according to the order in which the file appears. Therefore, the most reliable server should be provided first. Currently, up to three name servers are supported.


3./etc/sysconfig/Network File

This file is used to specify the network configuration information on the server. The following is an example:

Network = Yes

Rorward_ipv4 = Yes

Hostname = server.wuxp.com

Gareway = 192.168.0.1

Gatewaydev = eth0


Network = yes/no whether the network is configured

Forward_ipv4 = yes/no whether IP Forwarding is enabled

Hostname =
Gareway = <address> indicates the IP address of the Network Gateway.

Garewaydev = <device> indicates the gateway device name, for example, eth0.


4./etc/hosts file

When the machine starts, before the DNS can be queried, the machine needs to query the matching of some host names to IP addresses. The matching information is stored in the/etc/hosts file. Without a Domain Name Server, all network programs on the system query the file to resolve the IP address corresponding to a host name.

The following is an example of a/etc/hosts file:

127.0.0.1 localhost server.wuxp.com

192.168.0.3 station1.wuxp.com


The leftmost column is the Host IP information, and the middle column is the host name. All the columns that follow are aliases of the host.

Setup Configuration:

Select => Network Configuration

1. Edit devices:
Name: eth0
Device: eth0
Use DHCP: []
Static IP: 192.168.1.180
Netmask: 255.255.255.0
Default gateway IP: 192.168.1.1

2. Edit DSN Configuration:
Hostname: Any name (Kevin)
Primary DNS: 202.106.46.151
Secondary DNS: 8.8.8.8
Tertiary DNS: 8.8.4.4
Search: NULL

/Etc/init. d/network restart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.