Linux Network configuration and management

Source: Internet
Author: User

网络很重要!网络是一切网络服务的基础,没有网络,就不会有今天的BTA。现在的服务器主要是linux,所以linux的网络配置和管理很重要。

One, the introduction of network communication
The three elements of communication are: IP address, mask, route.
IP and netmask are required, and with these two conditions, local network communication can be implemented.
If you have ip,netmask,route, you can achieve cross-network segment communication.
There is also a point is DNS, domain name resolution.

Two, Linux network configuration
There are many ways to configure a network in Linux, and I'll show you how to configure the network in four directions below. From simple to difficult.
1, graphical interface mode
2, pseudo-graphical interface mode
3, command-line mode
4, configuration file mode
Can configure the network according to their own preferences, I personally prefer the command line to configure the network.
1, graphical interface (only available under init 5)
System command:
]# Nm-connection-editor

Double-click the network eth0 NIC you want to modify

Need to modify: Method----Address
Method: Select Manual
Address: Modify address, subnet mask, gateway, and DNS server
Save it.

2, pseudo graphical interface (init 3 and 5 mode can be used)
System command:
]# Nmtui

Enter on Enter

option requires a modified NIC entry


The configuration and graphical interface are similar.
Note: Select is to use the left and right selection, enter is OK

3, command-line configuration (Redhat 7.2)
]# nmcli Connection modify eth0 ipv4.method manual ipv4.addresses "192.168.4.52/24" Ipv4.gateway "192.168.4.254" Ipv4.dns "8.8.8.8" Connection.autoconnect Yes
]# nmcli connection up eth0
Translation: #网络连接命令 ---connection----Modify---NIC name---IP version 4. Method--Manual--IP version 4. Address----"IP address/Mask"--IP version 4. Gateway--"gateway address"--IP version 4. Domain Name Resolution "DNS Server"---connection. Auto Connect---Yes
#网络连接命令-Connect---Turn on---nic name
(English OK, you can go straight down)
]# nmcli con mo eth0 ipv4.method manual ipv4.add "192.168.4.52/24"
The command can be shortened with a long use time.
Experience:
In fact, many of the Linux commands are abbreviations for English words, and if English is good, it is easier to learn.

4, configuration file
Network configuration file:/etc/sysconfig/network-scripts/ifcfg-nic Name
]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Type=ethernet//interface type, common with Ethernet, Bridge
Bootproto=none//What protocol is used to configure interface properties when this interface is activated, typically DHCP, BOOTP, static, none
Defroute=yes
Ipv4_failure_fatal=no
Ipv6init=yes//whether to initialize IPV6
Ipv6_autoconf=yes
Ipv6_defroute=yes
Ipv6_failure_fatal=no
Name=eth0
Device=eth0//NIC Name
Onboot=yes//System boot process, whether this interface is activated
Unique identification of the UUID=5FB06BD0-0BB0-7FFB-45F1-D6EDD65F3E03//device
ipaddr=192.168.4.52//Network address
PREFIX=24//Mask
gateway=192.168.4.254//Gateway
Ipv6_peerdns=yes
Ipv6_peerroutes=yes
DNS configuration file
]# vim/etc/resolv.conf
NameServer 8.8.8.8//dns Server 8.8.8.8 is a DNS server for Google

Third, the management of the network
The content of network management is very much, usually use some tools to manage the network.
Firewall,selinux will have certain restrictions on network services, this article is not discussed for the time being.
Ifconfig command: Configure the view network interface can be with the network card name, view a network card information

Route command: Route view and Management
]# Route-n
-N: Indicates that the information is displayed numerically and does not reverse resolve the address and port number

Netstat command: View network status and statistics
I use the general is: NETSTAT-ANPTU | What grep wants to query (http/80,mysql/3306, etc.)
-t,–tcp:tcp the relevant connection of the Protocol, the connection has its state; FSM (finate);
Create a virtual link before the communication begins, and then remove the link after the communication is complete.
-U,–UDP:UDP related connections; non-connected protocols; sending data messages directly
-w:raw socket connection related to bare sockets
-L: Connection in listening state
-A: Connections for all States
-N: Displays IP and port in digital format;
-E: Extended format
-P: Show the relevant process and PID;

SS Command: Similar to the netstat command, but the query is faster than Netstat.

Refer to network resources: (more details)
Https://www.cnblogs.com/liangshaoye/p/5464601.html

Linux Network configuration and 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.