CentOS Network Configuration Example

Source: Internet
Author: User
Tags nameserver

1. Configure DNSVim/etc/resolv.conf

NameServer 192.168.0.1
NameServer 8.8.8.8

NameServer 8.8.4.4

2. Configure the Gateway route add default GW 192.168.1.1 Dev eno*

This changes the gateway to 192.168.1.1 , which is only temporary, when you restart the system or network card, it will be back to the original gateway. To make permanent changes, you need to modify /etc/sysconfig/network This file, the main content of this file (you do not have the file, you can manually add):

vim/etc/sysconfig/network

Networking=yes #表示系统是否使用网络, generally set to Yes. If set to No, the network is not available.

Hostname=centos #设置本机的主机名, the host name set here corresponds to the hostname set in/etc/hosts

gateway=192.168.1.1 #设置本机连接的网关的IP地址.

3. Configure the IP addressvim/etc/sysconfig/network-scripts/ifcfg-eno*

hwaddr=00:0c:29:8d:24:73
Type=ethernet
Bootproto=static #启用静态IP地址
Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=no
Ipv6init=yes
Ipv6_autoconf=yes
Ipv6_defroute=yes
Ipv6_peerdns=yes
Ipv6_peerroutes=yes
Ipv6_failure_fatal=no
name=eno16777736
Uuid=ae0965e7-22b9-45aa-8ec9-3f0a20a85d11
Onboot=yes #开启自动启用网络连接
ipaddr0=192.168.21.128 #设置IP地址
Prefixo0=24 #设置子网掩码
gateway0=192.168.21.2 #设置网关
dns1=8.8.8.8 #设置主DNS
dns2=8.8.4.4 #设置备DNS
: wq! #保存退出

4. Set the host name to www

Vim/etc/hostname #编辑配置文件

www #修改localhost. Localdomain for www

Vim/etc/hosts #编辑配置文件

127.0.0.1 localhost www #修改localhost. localdomain for www

5. Restart the service

IP link set eth0 UPI # Open Nic
IP link set eth0 down # close the NIC

Service Network restart

6. Supplementary order

IP [Options] Action object {Link|addr|route ...}

# IP Link Show # Displays network interface information
# IP Link set eth0 UPI # Open Nic
# IP Link set eth0 down # close NIC
# IP Link set eth0 promisc on # open NIC Mixed mode
# IP Link Set eth0 promisc offi # Turn off the network card mix mode
# IP Link Set eth0 txqueuelen 1200 # set NIC Queue Length
# IP Link Set eth0 MTU 1400 # set NIC Maximum transmission unit
# IP Addr Show # Displays network card IP information
# ip addr Add 192.168.0.1/24 dev eth0 # set eth0 NIC IP address 192.168.0.1
# ip addr del 192.168.0.1/24 dev eth0 # remove eth0 NIC IP address

# IP Route List # view routing information
# IP route add 192.168.4.0/24 via 192.168.0.254 Dev eth0 # Set the gateway for 192.168.4.0 segment to 192.168.0.254, Data walk eth0 interface
# IP route add default via 192.168.0.254 Dev Eth0 # to set the defaults gateway to 192.168.0.254
# ip Route del 192.168.4.0/24 # Remove gateway for 192.168.4.0 network segment
# IP Route del Default # to delete the defaults route

CentOS Network Configuration Example

Related Article

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.