Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RHCE Learning Notes (9) Network Management

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

N this section is supposed to learn SSH according to the syllabus, but SSH has a lot of network-related knowledge, so the teacher put the network content in advance. The basic knowledge of the network, such as IP,DNS,DHCP, routing protocols and other common sense is not explained here.

It is easy for RHEL to view the information about the network card, and ifconfig can view it. Notice that the name of the network card in RHEL7 has changed from eth0,1,2 to enoXXXXX. En stands for enthernet (Ethernet) and o for onboard (built-in). That string of numbers is automatically generated by some kind of index number on the motherboard to ensure its uniqueness. Compared with the original naming method, this new method is longer and difficult to remember, but the advantage is that the number is unique and it is not easy to make mistakes when doing system migration. Similar names include SXXX (module slot) and PXXX (usb device), which have nothing to do with the network, so I won't go into it.

In addition to ifconfig, you can also use ip address to view it. You can specify a specific network card through show.

Check the information of all network cards, which can even be simplified to ip a

Next, take a look at the Connection. A network card does not have an IP address and cannot communicate. Only after establishing a connection with him can you get the address and communicate with the outside world. Therefore, network card and connection are two separate concepts.

For example, I deleted all the network cards on the virtual machine.

Delete is confirmed in ifconfig, but the connection I created earlier still exists in nmcli connection show.

How to configure the connection? This can be achieved through graphical tools, the command line, or by modifying the configuration file

Method 1. Graphical tool

We can configure the connection through nm-connection-editor, and we can see that the previous connection is still there, although the bound network card is gone.

Add a network card as a test

Ifconfig can see the network card, but this network card does not have an IP address.

Open nm-connection-editor and create a new connection

Give me a name and bind the device address.

Here I will default to dhcp, which is automatically assigned by vmware workstation.

Once configured, restart the network service, and then look at ifconfig and find that you have obtained the new address

Once the connection is established, a configuration file with the same name will be automatically created under / etc/sysconfig/networks-scripts

Open it.

Next, let's look at how the command line works.

Method 2 nmcli command

Nmcli is a powerful command, followed by a host of options and objects that can be configured. Take a look at the help documentation. Objects can be comprehensive information, networks, signals and connections. Here we are mainly learning the configuration and use of the connection.

See what the effect is of entering different objects directly.

Next, let's take a look at the focus of our study, how to configure the connection, or take a look at the help first. He can follow show,up, down, add, modify, edit, delete, reload, and probably guess what it is for from the name.

In the experiment, I added another network card as a comparison.

Ifconfig looks at the network card information and can see that the second network card does not have an IP address.

Looking at the device information, you can see that the connection status of the second network card is disconnected (in fact, he is not connected at all)

By the way, take a look at what parameters device has to query. He has an option for connect. Try it, but it fails, indicating that there is no available connection to the device at all.

So let's make a new connection. Let's take a look at the help first. Beans like to use help before using the command, because the specific parameters can't be remembered at all, so it's necessary to look at the help.

Its basic format is nmcli connection add common line selection (type, device name, connection name, auto connection) device type (Ethernet, wifi, etc.) ip address

The bean adds a new connection according to the gourd painting, and it is created successfully.

Check the connection status. Successful.

So how to check the specific equipment information? Can be viewed by the nmcli connection show device name, for example

It contains all the relevant information, including common names, mac addresses, connection types, gateways, dns,mtu, etc.

To modify an attribute, you only need to use the format of the new attribute of the nmcli connection modify device name attribute name. The device name enoXXXXX and the attribute value connection.id can appear automatically through the tab key, so just write it down

For example, if I modify id and restart the network service, I can see that id has changed.

However, there is still no change in ifconfig, because the name of the device is fixed, and later it will demonstrate how to change to the previous naming method.

Next, try changing the ip address. Currently, DHCP automatically assigns it, so I need to modify the IP address first, and then change the configuration mode to manual

Then check whether the network card has updated the address and confirm the success.

After you have created a connection, you can also turn it off and open it through down and up.

In addition, I can view the gateway or DNS via nmcli connection sh enoXXX | grep route, or through the more traditional route and / etc/resolv.conf files.

For example, I use nmcli to add a DNS record.

After restarting the service, look at the / etc/resolv.conf file and change the

The ifconfig command itself can also modify the IP, but this is temporary and will be restored after restarting the service.

Method 3. Configuration file to modify the network

As mentioned earlier, the corresponding file is automatically generated after the connection is configured. We can create a new connection by copying and pasting a ready-made one.

Finally, let's take a look at how to modify the naming of the network card. Modify the following file / etc/default/grub file

Add the following settings

Then be sure to delete all current connection connections before the changes will take effect!

Recompile and restart the machine.

Modified successfully!

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.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report