11. Manage the network
1. Basic knowledge of ip
1.ipv4
binary 32 bits-----decimal
172.25.0.10/255.255.255.0
172.25.0.10: ip address
255.255.255.0: subnet
mask The ip bit corresponding to the subnet mask 255 bits is the network bit
The ip bit corresponding to subnet mask 0 is the host bit
####2. Configure ip####
<<graphical>>
1. Graphical interface
nm-connection-editor
2. Text graphics
nmtui
<<command>>
ifconfig network card ip netmask ##Temporarily set
nmcli connection add type ethernet con-name westos ifname eth0 autoconnect yes #Add dhcp network
nmcli connection add type ethernet con-name westos ifname eth0 ip4 ip /24 #Add static network
nmcli connection delete westos #Delete westos link
nmcli connection show #Show all network links
nmcli connection down westos #Close the specified link
nmcli connection up westos #Open the specified link
nmcli connection modify "westos" ipv4.addresses newip/24 #Change the ip of
wetos nmcli connection modify "westos" ipv4.method <auto|manual> #Change the working mode of westos to dynamic or static
nmcli device connect eth0 #Open the
device nmcli device disconnect eth0
#Close the device nmcli device show #Display device information
nmcli device status #Display device status
<<file>>
dhcp ##Get
vim dynamically /etc/sysconfig/network-scripts/ifcfg- eth0
DEVICE=eth0 ##The interface uses the device
BOOTPROTO=dhcp ##Network card working mode
ONBOOT=yes ##Automatic activation when the network service is turned on
NAME=eth0 ##Network interface name
: wq
systemctl restart network
static|none ##Static network
vim / etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 ##Device
BOOTPROTO=static|none ##Device working mode
ONBOOT=yes ##Enable network service to activate device
NAME=eth0 ##Network interface name
IPADDR=172.25.0.100 ##IP
NETMASK=255.255.255.0 | PREFIX=24 ##Subnet mask
DNS1=172.25.254.250 ##Set dns
GATEWAY=172.25.254.250 ##Gateway
# ###3.gateway gateway####
1.
The main function of the router is to use as nat's dnat
destination address translation
snat source address translation
2. The ip on the gateway
router that is in the same network segment as itself
3. Set Set gateway
systemctl stop NetwrokManager
vim /etc/sysconfig/network ##global gateway
GATEWAY=gateway ip
vim /etc/sysconfig/network-scripts/ifcfg-network card configuration file##network interface gateway
GATEWAY=gateway ip
systemctl restart netwrok
route -n ##Query gateway
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 (Gateway) 172.25.0.254 0.0.0.0 UG 0 0 0 eth0
172.25.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 #Note
: in
####5.dns####
1.dns
dns It is a server
. This server provides the function of answering the correspondence between the client's host name and ip.
2. Set dns
vim /etc/resolv.conf
nameserver dns server ip
vim /etc/sysconfig/network-scripts/ifcfg-network card configuration file
DNS1 =dns server ip
3. Local resolution file
vim /etc/hosts
ip host name
4. Local resolution file and dns read priority adjustment
/etc/nsswitch.conf
38 #hosts: db files nisplus nis dns
39 hosts: files dns ##files represents the local parsing file, dns represents the dns server, which
is the configuration of the first priority 5.dhcp service.
Tar
unpacking: tar xvf FileName.tar
Packaging: tar cvf FileName.tar DirName
(Note: tar is packaging, not compression!)
For advanced packaging, exclude several directories and specify the packaging path.
tar --exclude=var/www/ff-bb.cn/download --exclude=var/www/ff-bb.cn/download2 cfz hosteguide.com.tar.gz /var/www/hosteguide.com/
NOTE- The exclusion directory after -exclude cannot be followed by /, otherwise it will not work. tar is described in detail below.
———————————————
6 Compression, decompression .gz
decompression 1: gunzip FileName.gz
decompression 2: gzip -d FileName.gz
compression: gzip FileName
.tar.gz and .tgz
decompression: tar zxvf FileName.tar.gz
Compress: tar zcvf FileName.tar.gz DirName
———————————————
.bz2
Decompress 1: bzip2 -d FileName.bz2
Decompress 2: bunzip2 FileName.bz2
Compress: bzip2 -z FileName
.tar.bz2
Extract: tar jxvf FileName.tar.bz2
Compress: tar jcvf FileName.tar.bz2 DirName
———————————————
.bz
decompression 1: bzip2 -d FileName.bz
decompression 2: bunzip2 FileName.bz
compression: unknown
.tar.bz
decompression: tar jxvf FileName.tar.bz
compression : unknown
———————————————
.Z
decompress: uncompress FileName.Z
compress: compress FileName
.tar.Z
decompress: tar Zxvf FileName.tar.Z
compress: tar Zcvf FileName.tar. Z DirName
———————————————
.zip
decompress: unzip FileName.zip
compress: zip FileName.zip DirName
———————————————
.rar
decompress : rar x FileName.rar
Compression: rar a FileName.rar DirName
———————————————
.lha
decompression: lha -e FileName.lha
压缩:lha -a FileName.lha FileName5.dns
1. Management of the
virtual machine The system and hardware of the virtual machine are saved in
/var/lib/libvirt/images/westos.qcow2 ##system /etc/libvirt/qemu/
westos.xml ##hardware
creation snapshot
qemu-img create - f qcow2 -b westos.qcow2 node1.qcow2
create ##New file -f qcow2 ##File type
-b westos.qcow2 ##Original file node1.qcow2 ##Snapshot file
virsh create westos.xml ##Temporarily open the virtual machine
Note : When backing up and re-installing, first copy westos.qcow2 to the /var/lib/libvirt/images/ directory
virsh define westos.xml ##Install the virtual machine, but will not open it directly (permanently)
virsh start westos ##Open the virtual machine Machine
virt-viewer test ##Display the virtual machine
virsh shutdown test ##Close the virtual machine
virsh destroy test ##Forcibly shut down the virtual machine
virsh undefine westos.xml ##Delete the virtual machine front end
Note: You need to put /var/lib/libvirt/images Delete the westos.qcow2 file in the / directory
virsh list ##List running virtual machines
virsh list --all ##List all installed virtual machines