Linux Network Configuration

Source: Internet
Author: User
Tags network function

 

I. How to configure the Host Name:

1./etc/sysconfig/network

NETWORKING = yes (disable the network function)

NETWORKING_IPV6 = no (disable ipv6)

HOSTNAME = localhost. localdomain (set host name)

It cannot take effect immediately after the configuration is complete.

You can restart the network service:

Service network restart

/Etc/init. d/network restart (same effect as above)

 

2. view the/proc/sys/kernel/hostname file by hostname

Echo "exlinux.example.com">/proc/sys/kernel/hostname

/Proc/sys/kernel/hostname this file cannot be opened with vim, but only the redirection method can be used

Upload content to it.

 

II. Four methods to configure Nic information:

1.

System-config-network-gui display gui

Ethx --> Ethernet NIC

Pppx --> ppp Nic

Ppp0, ppp1 ,...

 

FQDN: Full Qualified Domain Name (Full Domain Name)

2. setup

System-config-network-tui

Configure the nic and dns in the image

3.

/Etc/sysconfig/network-scripts/ifcfg-eth

DEVICE = eth0 (NIC)

HWADDR = (NIC mac address)

BOOTPROTO = {dhcp | bootp | static | none} (address acquisition method)

IPADDR = (IP address)

NETMASK = (subnet mask)

GATEWAY = (Default GATEWAY)

ONBOOT = {yes | no} whether to start after adjustment

USERCTL = {yes | no} whether to allow common users to set the NIC (usually no)

PEERDNS = {yes | no} is used when the boot protocol is dhcp or bootp. If it is set to no

The dhcp Service or bootp service cannot change the host's dns configuration.

(Bootp is the predecessor of dhcp, but it does not have the lease function)

Disable an ifdown Device

Ifup enabled device

Ifdown eth0 & ifup eth0 (if disabled successfully, enable it)

 

4.

Ifconfig ethX IP/NETMASK)

Service network restart becomes invalid

Neither method 3 nor Method 4 can configure dns

3. How to configure dns:

Vim/etc/resolv. conf set dns here

Search followed by search domain

Eg: search a.com

A.com is automatically added when you ping www.

Nameserver dns server address

At most one domain name corresponds to three

4. How to add a gateway:

Route add-host IP gw GATEWAY

Route add-net NETWORK/NETMASK gw GATEWAY

Route add-net 0.0.0.0/0.0.0.0 gw GATEWAY

Route add default gw GATEWAY (add default GATEWAY)

5. How to delete route information:

Route del-host IP

Route del-net NETWORK/NETMAS

 

This article is from the "Wei's Linux bar" blog

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.