“This is the 27th day of my participation in the August Gwen Challenge.
The vast sea of millions, thank you for this second you see here. Hope my article is helpful to you!
May you keep your love and go to the mountains and seas in the coming days!
Linux advanced commands
Yesterday we have learned the command of Linux service management, know how to view some services in Linux, to manage the status of these services, or we can also set some services to start the state, there is no need to start the service itself. Of course, we learn more than that. Today we learn about Linux network management commands! Let ‘s GO!
Linux network management
Network management – host name management
Command:
Hostname: View the name of the computer
Hostnamectl set-hostname name: Permanently changes the computer name, requiring a reboot or bash refresh
Presentation:
Network management – Network service management
Command related:
- SystemctI start network: starts network services
- Systemctl stop network: stops network services
- Systemctl restart network: restarts the network service
- Systemctl status network: Views the status of the network service
Client operations:
Vm server operations:
Back to client operations:
Network management – nic activation and shutdown management
Through the previous learning, we also know how to view the network card list
ifconfig
Copy the code
Note: All Linux nics have corresponding configuration files in the /etc/sysconfig/network-scripts/ directory.
1. How do I turn off the nic?
-
Find the nic configuration file ENS33
cd /etc/sysconfig/network-scripts/ Copy the code
-
Edit the nic configuration file
vim ifcfg-ens33 Copy the code
Enter the configuration file information and modify the ONBOOT configuration to disable the NIC
- The ONBOOT property is used to start or shut down the management network adapter
- ONBOOT=yes Activates and starts the NIC
- ONBOOT=no Indicates that the NIC is disabled
ONBOOT=no Copy the code
-
Restart the network service to recognize the latest changes
systemctl restart network Copy the code
-
You can then test networking in the virtual machine server
2. Activate the NIC again
-
Modify the ifcfg-ens33 configuration file on the VM to enable the NIC
ONBOOT=yes Copy the code
-
Restarting the Network Service
systemctl restart network Copy the code
-
After testing the network, it was found to be normal.
Network management – Configure static IP
As we know, the default Linux vm uses DHCP to dynamically generate IP, which is unstable and occasionally changes. In the future, the Linux system as a server is to provide services to the outside, so the IP cannot be changed should be fixed, so how to achieve it?
1. IP address type
DHCP, IP is dynamically allocated to generate, suitable for personal computers
==static, the IP address is static, suitable for the server, cannot change ==
The IP address of the server cannot be changed. Otherwise, the client segment cannot find the server
2. Query the gateway information of VMNet8 nic in NAT mode
3. Configure a static IP address
Modify the static IP address in the Linux NIC configuration file ifcfg-ens33
-
Go to the configuration file directory
cd /etc/sysconfig/network-scripts/ Copy the code
-
Editing a Configuration File
vim ifcfg-ens33 Copy the code
-
Modify the following and save
Details of additions and modifications:
Example Change the generation type of an IP address (DHCP) to static
BOOTPROTO=static Copy the code
-
IPADDR Indicates the IP address
-
GATEWAY Configure the GATEWAY.
-
NETMASK Configures the subnet mask
-
DNS1 Configure the preferred DNS
-
DNS2 Configure alternate DNS
IPADDR=192.168.66.128 GATEWAY=192.168.66.2 NETMASK=255.255.255.0 DNS1=223.5.5.5 DNS2=114.114.114.114 Copy the code
-
-
Restarting the Network Service
systemctl restart network Copy the code
Network management – VM snapshots
Virtual machine due to its unstable, virtual machine often through some configuration or software installation lead to the system is not available, we generally reinstall the VIRTUAL machine Linux system to solve the problem, so this operation is a waste of time, there is no good way to reinstall the system?
Set the system snapshot when the system is available (no problems), and restore the snapshot when the system is not available!
1. Snapshot introduction
A VM snapshot is a copy of a VM disk file at a point in time. System crash or system exception, you can specify the system state by using the restore to snapshot point in time. When it comes to upgrading and patching applications and servers, snapshots are the saviour. VMware snapshots are a feature in VMwareWorkstation.
2. Implementation steps
-
Generate a snapshot
Click on the menu to manage the snapshot
-
Create a snapshot to generate a copy of the current operating system disk file (equivalent to backing up a system)
-
When the system is unavailable, you can restore the system using the specified snapshot
Network management – clone virtual computer
Enterprise development often needs to prepare multiple identical virtual machines Linux system environment, so how to quickly build multiple identical virtual machines according to the current virtual machines?
Virtual machine cloning, you can clone a number of identical virtual computers
Implementation steps:
-
Shut down the Linux operating system on the current VM
-
Select and click the current Linux system virtual computer, and then right-click the mouse as shown in the figure
Note: Must be closed before cloning, then select full clone.
-
Example Modify a cloned static IP address
Change the static IP address of the cloned COMPUTER to 192.168.66.129 and ensure that the IP address is different from that of the original VM.
-
Change the name of the computer
Use bash to refresh.
Network management – Query the port number used by network processes
In enterprise development, it is often necessary to query the port number used by software. How to query the port number used by a certain running software in Linux?
Command:
Netstat: displays the system network information
Parameter details:
No arguments | Display network Status | |
---|---|---|
-n | number | Displays the IP address and port number of the program |
-t | tcp | Only TCP programs are displayed. -u displays UDP programs |
-l | listenter | Displays the Socket listening |
-p | programs | Displays the name of the program |
Presentation:
Netstat -nutlp # check port, UDP, TCP, listening, display program name
Common commands:
- Netstat -ntlp: checks only TCP
- Netstat -nulp: checks only UDP
- Netstat-nutlp: checks only UDP and TCP
conclusion
I believe that you are on the Linux system of network management commands have a certain understanding, looking forward to waiting for the next chapter of Linux in the advanced command on how to set up the firewall learning bar!
Of course, there are more commands to watch next time! Welcome to the next chapter!
Let’s refuel together, too! I am not just, if there is any missing, wrong place, also welcome you to criticize in the comments of talent leaders! Of course, if this article is sure to help you a little, please kindly and lovely talent leaders to give a thumb-up, favorites, one key three even, thank you very much!
Here, the world is closed for today, good night! Although this article is over, I am still here, never finished. I will try to keep writing articles. The coming days are long, why fear the car yao ma slow!
Thank you all for seeing this! May you live up to your youth and have no regrets!