Linux Network-related commands and linux Network-related commands

Source: Internet
Author: User

Linux Network-related commands and linux Network-related commands

Ifconfig is the command to view the NIC in centos6. In centos7, you must install the net-tools package before using it?
Nic configuration file:/etc/sysconfig/network-scripts/ifcfg-ens33?
Command: ifconfig

[root@shuai-01 ~]# ifconfigens33: flags=4163
    mtu 1500        inet  netmask  broadcast        inet6 fe80::16f5:8ee4:b971:e6fb  prefixlen 64  scopeid 0x20
          ether 00:0c:29:a1:0e:2c  txqueuelen 1000  (Ethernet)        RX packets 236  bytes 23351 (22.8 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 216  bytes 25791 (25.1 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73
     mtu 65536        inet  netmask        inet6 ::1  prefixlen 128  scopeid 0x10
            loop  txqueuelen 1  (Local Loopback)        RX packets 68  bytes 5524 (5.3 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 68  bytes 5524 (5.3 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Disable NIC:

ifdown ens33

Enable NIC:

ifup ens33

When the network card is disabled, it cannot be remotely connected. Especially when you are using this Nic.

To restart an Eni:

[Root @ shuai-01 ~] # Ifdown ens33 & ifup ens33 disconnect the device 'ens33 '. Successfully activated connections (D-Bus activation path:/org/freedesktop/NetworkManager/ActiveConnection/1)

To restart the network service:

service restrat network
Set multiple ip addresses for one network card

One Nic can have multiple IP addresses. How can I set a virtual IP address for one Nic?
Enter the NIC configuration file and copy a configuration file

[root@shuai-01 ~]# cd /etc/sysconfig/network-scripts/[root@shuai-01 network-scripts]# lsifcfg-ens33  ifdown-ppp       ifup-ib      ifup-Teamifcfg-lo     ifdown-routes    ifup-ippp    ifup-TeamPortifdown       ifdown-sit       ifup-ipv6    ifup-tunnelifdown-bnep  ifdown-Team      ifup-isdn    ifup-wirelessifdown-eth   ifdown-TeamPort  ifup-plip    init.ipv6-globalifdown-ib    ifdown-tunnel    ifup-plusb   network-functionsifdown-ippp  ifup             ifup-post    network-functions-ipv6ifdown-ipv6  ifup-aliases     ifup-pppifdown-isdn  ifup-bnep        ifup-routesifdown-post  ifup-eth         ifup-sit[root@shuai-01 network-scripts]# cp ifcfg-ens33 ifcfg-ens33:0

Vi new configuration file change information: NAME, DEVICE, IPADDR, GATEWAY, DNS



Restart the NIC after saving and exiting:

[root@shuai-01 network-scripts]# ifdown ens33 && ifup ens33
View the connection status of the ENI

Command: mii-tool

[root@shuai-01 network-scripts]# mii-tool ens33ens33: negotiated 1000baseT-FD flow-control, link ok

Link OK indicates the connected network cable?
Command: ethtool

[root@shuai-01 network-scripts]# ethtool ens33Settings for ens33:    Supported ports: [ TP ]    Supported link modes:   10baseT/Half 10baseT/Full                             100baseT/Half 100baseT/Full                             1000baseT/Full     Supported pause frame use: No    Supports auto-negotiation: Yes    Advertised link modes:  10baseT/Half 10baseT/Full                             100baseT/Half 100baseT/Full                             1000baseT/Full     Advertised pause frame use: No    Advertised auto-negotiation: Yes    Speed: 1000Mb/s    Duplex: Full    Port: Twisted Pair    PHYAD: 0    Transceiver: internal    Auto-negotiation: on    MDI-X: off (auto)    Supports Wake-on: d    Wake-on: d    Current message level: 0x00000007 (7)                   drv probe link    Link detected: yes

Link detected: yes indicates the network connection.

Change Host Name

Command: hostnamectl?
Command Format: hostnamectl set-hostname Host Name

Host Name configuration file:/etc/hostname

Set dns

Dns configuration file:/etc/resolv. conf

View the dns configuration file:

[root@shuai-01 network-scripts]# cat /etc/resolv.conf # Generated by NetworkManagernameserver

Can I change the dns in the NIC configuration file or in the dns configuration file?


In the dns configuration file (temporary ):


The custom dns domain name takes effect on the local machine. After the definition, you do not need to enter the dns resolution domain name .?
Configuration File:/etc/hosts

Add a DNS domain name:

[root@shuai-01 network-scripts]# vim /etc/hosts

Add DNS domain name:


[root@shuai-01 network-scripts]# ping ( 56(84) bytes of data.[root@shuai-01 network-scripts]# ping www.qq.comPING ( 56(84) bytes of data.
  • One IP address can be followed by multiple domain names
  • One row can have only one IP Address

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: 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.