Linux Network Management--Basic command of network management

Source: Internet
Author: User
Tags uuid

Linux mainly uses three types of network management commands: 1.ifconfig, route and Netstat belong to the traditional function of single-class network command; 2.ip and SS belong to the Integrated class Network command; The 3.NMCLI is suitable for comprehensive network commands in RHEL7, and can also be configured with a configuration file for network management.

This article mainly explains these three kinds of network Management command and the related configuration file.

Note: The network parameters modified by the command are lost after the network service restarts, and only the network parameters modified by the configuration file can be permanently valid.


1-1. ifconfig Command

Function: View or configure network interface parameters

Format:

Ifconfig [interface] [Up|down] view specified network interface parameters, set network interface status

Common options:

-A: Show all network interface information

-S: Display network interface statistics 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/72/9F/wKioL1XpkHCjplYGAAIkgqmutNI847.jpg " Style= "Float:left;" title= "Network management--ifconfig01.jpg" alt= "Wkiol1xpkhcjplygaaikgqmutni847.jpg"/>











The default Ifconfig only displays the active network interface and does not disappear. Turn off network interface parameters

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/9F/wKioL1XpkHGDDaZbAANyA9EBJe4717.jpg "title=" Network management--ifconfig02.jpg "alt=" Wkiol1xpkhgddazbaanya9ebje4717.jpg "/>


ifconfig INT address Configure IP addresses for specified network interfaces

ifconfig int ip/mask or ifconfig int IP netmask MASK modifies the IP address of the specified device

# When configuring an IP address, if the mask uses dotted decimal notation, you must use the keyword network

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/A3/wKiom1XpkAzRJUmWAAIa5WJWmX4934.jpg "title=" Network management--ifconfig03.jpg "alt=" Wkiom1xpkazrjumwaaia5wjwmx4934.jpg "/>


1-2. Route command

Role: View or configure a local routing entry

Format:

Route View Routing Entry

Options:

-N: Do not parse the domain name and display it with an IP address

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/A3/wKiom1XpmOqAEdbEAAHCFSzGhbg120.jpg "title=" Network management--route01.jpg "alt=" Wkiom1xpmoqaedbeaahcfszghbg120.jpg "/>


Route Add-net|-host|default TARGET [netmask MASK] [GW GW] [mertic N] [Dev INT]

Route del -net|-host|default TARGET [netmask MASK] [GW GW] [Dev INT]

Add or remove a route entry

Host route entry using keyword-host, network routing entry using keyword-network, default route entry using keyword default

Mertic N: Used to specify route entry metrics

Dev INT: Specify the Fight interface


Add host route entry Route Add-host 1.1.1.1 GW 10.10.10.1 metric Dev eth1

The next hop address is: 10.10.10.1, the route entry measure is 15, the outbound interface is eth1

Network routing entry route add-net 3.3.3.0/24 metric 7 Dev eth0

The measure value is 7 and the outbound interface is eth0

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/9F/wKioL1XpmyOhkJ4lAALiGq_s-Lk689.jpg "style=" float: none; "title=" Network management--route02.jpg "alt=" Wkiol1xpmyohkj4laaligq_s-lk689.jpg "/>

To delete a network route entry

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/A3/wKiom1XpmP6gXX4BAAI07ig4sdo766.jpg "style=" float: none; "title=" Network management--route03.jpg "alt=" Wkiom1xpmp6gxx4baai07ig4sdo766.jpg "/>


1-3. Netstat command

Function: View the network properties of this computer by specifying options

Format: netstat [options]

Common options:

-N: Digital display of IP and ports

-T: Show TCP connections

-u: Show UDP connections

-L: In the Listening State port

-A: all States

-E: Extended format

-P: Show related processes and PID

-R: Show kernel routing table

-I INT: Displays statistics for the specified interface


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/9F/wKioL1XpoAKSTQYyAAGeVOTUGbY411.jpg "title=" Network management--netstat-01.jpg "alt=" Wkiol1xpoakstqyyaagevotugby411.jpg "/>

=============================================================

2-1. IP command

Function: Configure the Native interface status, network parameters and routing entries

Format: IP [OPTIONS] OBJECT {COMMAND | help}

when object is link , configure the two-Layer link property configured for the native

The corresponding command is:

IP link set DEVICE {up | | \ arp {on | off}: Set two-layer link interface status

IP link Show [device]: View device properties

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/A3/wKiom1XpoQXBImFYAAK1s1FJ2pM368.jpg "title=" Network management--ip01.jpg "alt=" Wkiom1xpoqxbimfyaak1s1fj2pm368.jpg "/>


Used to set the native IP address when object is address

The corresponding command is:

IP Addr {add | del} ifaddr dev STRING: Add or remove IP addresses to the specified network interface

IP Addr {show | flush} [Dev STRING]: View or empty the IP address of the specified device

Add Ip/mask: Adding addresses to devices

Delete IP: Remove the address of the device configuration

Flush: Empties the configuration from the specified device

Show: View IP address configuration


Add a specified IP address via the add command

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/A4/wKiom1XprxaRKAoWAADvQEIF_us279.jpg "title=" Network management--ip03.jpg "alt=" Wkiom1xprxarkaowaadvqeif_us279.jpg "/>


Specify all IP addresses for the network interface through flush conditions

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/A4/wKiom1Xprv3yJlvgAAKWZ3LbtLo557.jpg "style=" float: none; "title=" Network management--ip02.jpg "alt=" Wkiom1xprv3yjlvgaakwz3lbtlo557.jpg "/>


Used to set the native route entry when object is a route

The corresponding command is:

IP route {list | flush} SELECTOR: View or empty route entry

IP route {Add | del | change | append | replace | monitor} route: Modify route entry


Add a route entry via the Add command

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/A0/wKioL1XptSOSu7iSAAE9a25iHwo172.jpg "style=" float: none; "title=" Network management--ip04.jpg "alt=" Wkiol1xptsosu7isaae9a25ihwo172.jpg "/>


To modify a route entry by using the change command

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/A4/wKiom1Xpsv6DCr0sAAFF5OaDeAk922.jpg "style=" float: none; "title=" Network management--ip05.jpg "alt=" Wkiom1xpsv6dcr0saaff5oadeak922.jpg "/>


2-2. SS command

Function: Specify options to display the local network parameters

# The SS command works the same as the Netstat command, but the execution is more efficient and the SS command is recommended when the system is busy

Format: SS [Options]

Common options:

-N: Digital display of IP and ports

-T: Show TCP connections

-u: Show UDP connections

-L: In the Listening State port

-A: all States

-E: Extended format

-P: Show related processes and PID

-R: Show kernel routing table

-I INT: Displays statistics for the specified interface

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/A4/wKiom1XptTOCTXJzAAGeNlzw8vI844.jpg "title=" Network management--ss-01.jpg "alt=" Wkiom1xpttoctxjzaagenlzw8vi844.jpg "/>

=============================================================

3-1. NMCLI command

The NMCLI command is a command-line tool for managing NetworkManager in RHEL7, and Nmcli is a powerful, flexible command, but also very complex. This is only a brief introduction to NMCLI's connection and device two objects.

Role: Used to create, display, edit, delete, activate and deactivate network connections

Format: nmcli [OPTIONS] OBJECT {COMMAND | help}

# NMCLI supports tab completion for object and COMMAND input, is more user-friendly, and has a corresponding help option in all levels of object, which brings great convenience when used.


When object is connection ,

corresponding command: = {Show | up | down | add | edit | modify | delete | reload | load}

The main implementation of the local network connection status of the view, management and other operations

Management of local network connections via connection

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/AC/wKiom1Xq8bXSxj9OAAOD5aeX88E383.jpg "style=" float: none; "title=" Network management--nmcli01.jpg "alt=" Wkiom1xq8bxsxj9oaaod5aex88e383.jpg "/>


Various parameters of network connection can be modified by modify subcommand

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/A8/wKioL1Xq89yB5NrAAAPhNLHp9k0516.jpg "style=" float: none; "title=" Network management--nmcli02.jpg "alt=" Wkiol1xq89yb5nraaaphnlhp9k0516.jpg "/>


When object is a device ,

corresponding command: = {Status | show | connect | disconnect | delete | wifi | wimax}

For viewing and managing on-premises network interface devices


Detailed configuration information for network interfaces can be viewed through the SHOW subcommand

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/AD/wKiom1Xq9BiDLlzGAAKAfy1o3X8331.jpg "title=" Network management--nmcli03.jpg "alt=" Wkiom1xq9bidllzgaakafy1o3x8331.jpg "/>

=============================================================

4. Modifying network parameters through configuration files

4-1. IP address configuration file:/etc/sysconfig/network-scripts/ifcfg-int

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/A0/wKioL1XpvQmDfUDaAAGelSYwJsc565.jpg "title=" Network Management--configuration file 01.jpg "alt=" Wkiol1xpvqmdfudaaagelsywjsc565.jpg "/>


Field Explanation:

# Cat Ifcfg-eth0
Device= specifying the device name
bootproto= Specify IP Address acquisition method: DHCP or static
Hwaddr= specifying the hardware NIC MAC address
Nm_controlled= NM represents the NetworkManager script to replace the network protocol

Peerdns= indicates whether DNS received by the server is overwritten in the DNS configuration file if the IP address is obtained by DHCP

onboot= Specifies whether to start the network adapter device automatically
type= Display Network Interface type
Uuid= the UUID of the specified device
Ipv6init= whether the IPV6 feature is enabled
userctl= Specifies whether a normal user controls the device


Static IP addresses require the following fields to be configured:
Ipaddr= Specify IP Address
netmask= Subnet Mask
gateway= Default Gateway
dns#= DNS server address, 3 DNS server addresses can be configured at the same time, with higher priority than DNS configuration in/etc/resilov.conf


4-2. Routing configuration file:/etc/sysconfig/network-scripts/route-int

# Configuration files need to be created manually

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/A0/wKioL1XpvdzAJ_NKAADVJiJKJnQ561.jpg "title=" Network Management--configuration file 02.jpg "alt=" Wkiol1xpvdzaj_nkaadvjijkjnq561.jpg "/>


File format

1. Single Statement format

TARGET via GW

Ex:192.168.50.128/28 via 10.10.10.11

2. Define one route per three lines

Address#=target

Netmask#=mask

Gateway#=gw

EX:

address0=192.168.50.128

netmask0=255.255.255.224

gateway0=10.10.10.11


# only one format can be used in the same file


4-3. DNS configuration file:/etc/resolove.conf

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/A1/wKioL1XpzUmTkWLkAAD3ZcRn9Pw313.jpg "title=" Network Management--configuration file 03.jpg "alt=" Wkiol1xpzumtkwlkaad3zcrn9pw313.jpg "/>


To specify a DNS server by nameserver dns_ip


I have limited level, if there is improper understanding of the place, please give correct, thank you very much!


This article is from the "Pavel" blog, make sure to keep this source http://pavel86.blog.51cto.com/8349178/1691648

Linux Network Management--Basic command of network management

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.