In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
In view of the fact that the most important problem for different user groups and different businesses when using Linux system is to solve the problem of network connection, write this blog post.
This paper mainly summarizes the brief configuration of network card in CentOS and Ubuntu systems and the difference of three tools commonly used in managing network card (network, NetworkManager, ifup/ifdown). In particular, I have studied the three network management tools for nearly half a month, and finally achieved initial results. I hereby record and share them.
I. brief configuration of the network card configuration file
Combined with my short experience, most servers that install Linux systems choose CentOS when choosing Linux distributions, and occasionally Ubuntu systems.
The CentOS system network card configuration file is in the / etc/sysconfig/network-scripts/ directory, and each network card has a corresponding configuration file in this directory.
For example: edit the network card eth0
[root@localhost Desktop] # vim / etc/sysconfig/network-scripts/ifcfg-eth0
The network card dynamically acquires network parameters through DHCP.
Device name of the DEVICE= "eth0" Nic
BOOTPROTO= "dhcp" acquires network parameters through dhcp
MAC address of HWADDR= "00:0C:29:35:6C:C0" network card
ONBOOT= "yes" whether the network card is started by default
The device ID of the UUID= "3ebfdb25-ac76-4a3e-871f-5084c085ec46" network card
Type use of TYPE= "Ethernet" Nic (not necessary)
NM_CONTROLLED= "yes" additional network management software (not necessary)
The network card specifies the network parameters manually
DEVICE= "eth0"
BOOTPROTO= "static" by manually specifying network parameters
HWADDR= "00:0C:29:35:6C:C0"
ONBOOT= "yes"
UUID= "3ebfdb25-ac76-4a3e-871f-5084c085ec46"
IPADDR=192.168.1.1IP
NETMASK=255.255.255.0 mask
GATEWAY=192.168.1.254 Gateway
DNS1=202.207.177.3 Master DNS
DNS2=202.207.177.4 from DNS
The Ubuntu system network card configuration file is in the / etc/network/interfaces file, and the configuration parameters of each network card can be written in this file.
For example, edit the network card eth0 in the Ubuntu system
Root@lgq-virtual-machine:~# vi / etc/network/interfaces
The network card dynamically acquires network parameters through DHCP.
Auto eth0
Iface eth0 inet dhcp
The network card specifies the network parameters manually
Auto eth0
Iface eth0 inet static
Address 192.168.1.10
Netmask 255.255.255.0
Gateway 192.168.1.254
Dns-nameservers 202.207.177.3
Dns-nameservers 202.207.177.4
Finally, save and exit and restart the network.
2. The similarities and differences of network, NetworkManager and ifup/ifdown in network management (in CentOS system)
Before you understand these three tools, you need to pay attention to a parameter ONBOOT=yes/no in the corresponding Nic configuration file in the / etc/sysconfig/network-scripts/ directory (which means above)
NetworkManager is a third-party network management software used to manage available network cards, wireless, and broadband connected to a computer. It is powerful and provides a friendly graphical interface software to configure and manage the network card. The configuration of the network card will be directly synchronized to the corresponding network card configuration file in the / etc/sysconfig/network-scripts/ directory, and the changes in the parameters in this configuration file will also be reflected in the NetworkManager management software. When using this software to connect or disconnect the selected network card, the value of NOBOOT will be ignored, that is, when the ONBOOT value is no, NetworkManager will also start the network card temporarily.
-
Ifup/ifdown is functionally equivalent to enabling / disabling the right button after the local connection is selected in Windows. The combination of the two tools can be used to restart the network card (refer to the corresponding network card configuration file in the / etc/sysconfig/network-scripts/ directory). If you use the ifup eth0 command, like NetworkManager, the value of NOBOOT will be ignored, that is, the Nic will be temporarily started when the ONBOOT value is no, but the command ifup eth0 boot command will agree with the ONBOOT value, that is, only if the ONBOOT value is yes will the Nic be restarted successfully.
-
When executing service network restart, network will restart all NICs by referring to the corresponding Nic configuration file in the / etc/sysconfig/network-scripts/ directory. Since the command restarts the Nic by calling the ifup eth0 boot command, the Nic will be restarted only if the ONBOOT value is yes.
Summary: the disconnected state of the network card will be reflected in the NetworkManager software, as long as the NetworkManager software is turned on (service NetworkManager start). The results of using ifup/ifdown and network tools to manage the network card will naturally be reflected in the NetworkManager software. In view of the strength of NetworkManager, I suggest you use this software to manage your own network.
III. Several network-related tools commonly used in CentOS systems
Ip a 、 ifconfig 、 router 、 netstat 、 nmap 、 host 、 nslookup 、 ping 、 tracerout
Ip a: the easiest command to view the network parameters of the network card, you can view the IP, mask, MAC and other information of the network card. The ip command tool is very powerful, basically integrating all the functions of the ifconfig and route commands.
-
The ifconfig: ifconfig device name command can also view the receiving and sending of packets and other information compared to the ip a command.
-
Router: you can view the routing information of the network card. The route-n command is often used. The-n option means that the host name corresponding to ip is not used. The route command can also add (route add) and delete (route del) routing entries to the network card.
-
Ping: report the connection information of two PC or two network nodes in the network through icmp packet information. The commonly used options are-c,-t, and so on.
-
Traceroute: relative to the ping command, you can detect and report all node ip information that passes between the two hosts. The commonly used option is-n, which means that the host name corresponding to ip is not resolved, which is faster. The tracert command is used in Windows.
-
Netstat: commonly used to check the connection status of services on the host, such as which service processes are in the listening state (netstat-tlunp) and the number of client processes connected to the machine (netstat-atunp).
-
Nmap: a powerful tool that can be used to scan which services are enabled under which ports on specified hosts, and to detect the information of hosts enabled in a certain network segment. Common options are-sT,-sU,-sP
-
Host: used to view the ip corresponding to a hostname. Usage host hostname
-
Nslookup: similar to the host tool, it is used to view the ip corresponding to a hostname. You can also use the nslookup command in windows.
If the content of this blog is incorrect or unclear, please point out that you can't thank you enough!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.