IP and subnet mask concepts
1. What is IP ADDRESS
internet protocol ADDRESS ## network process address
ipv4 internet protocol version 4
ip is composed of 32 01s
11111110.11111110.11111110.11111110 = 254.254.254.254
2. Subnet mask
Used to divide the network area
The number on the ip corresponding to the non-zero bit of the subnet mask represents the network bit of this ip
The number corresponding to bit 0 of the subnet mask is the host bit of the ip
The network bit represents the network area
The host bit represents a host in the network area
3.ip communication judgment
Two IP S with the same network bit and inconsistent host bit can communicate directly
172.25.254.1/24 (24=255.255.255.0)
172.25.254.2/24
172.25.0.1/16 cannot communicate with the above ip
2, Temporary management network card
Note: it is called temporary. When the network card is restarted, the configuration is restored to its original appearance
1. Related commands
ip a ##View ip information ifconfig ##View ip information ping ##Check whether the network is unobstructed ping -c 1 ##Ping once ping -w 1 ##Wait 1 second ping -c1 -w1 ip ##ping1 time, wait 1 second ifconfig ##View or set network interface ifconfig ##see ifconfig device ip/24 ##set up ifconfig device down ##close ifconfig device up ##open ip addr ##Detect or this network interface ip addr show ##testing ip addr add ip/24 dev device ##set up ip addr del dev ens160 ip/24 ##delete
"Note: the name of the device is a physical fact. You can only use what life word you see, such as ens3
3, Permanent management network card
Make sure the service is turned on first
1. Set the network graphically
nm-connection-editor #####Open graphics nmcli connection shoW ######Displays information about network links nmcli connection down westos ######Turn off the westos network card nmcli connection reload #####Refresh link nmcli connection up westos #####Restart the specified connection
Note: change is different from direct creation. If it is new, it will take effect directly
The changes are only saved, but the configuration file cannot take effect immediately. It needs to be reloaded with the command. You can see the operation in the following picture
2. Image configuration network based on nmtui text model
Note: in this way, the newly created network configuration will take effect immediately. If you change it, you need to command reload to take effect
3. nmcli command mode setting network
nmcli ##NetworkManager must be enabled
nmcli device connect ens3 ##Enable ens160 network card nmcli device disconnect ens3 ##Turn off the network card nmcli device show ens3 ##View network card information nmcli device status ens3 ##View network card service interface information nmcli connection show ##View connections nmcli connection down westos ##Close connection nmcli connection up westos ##Open connection nmcli connection delete westos ##Delete connection #add connections nmcli connection add type ethernet con-name westos ifname ens160 ip4 172.25.254.100/24 #change nmcli connection modify westos ipv4.addresses 172.25.254.200/24
When there is no graphic operation, the modification of ip can not take effect immediately. It is still the old method
4. Set up the network by managing the network profile
- The network configuration directory is in / etc / sysconfig / network scripts/
- The configuration file must start with ifcfg -, such as ifcgf-ens3
Some contents in the document:
. | explain |
---|---|
DEVICE= xxx | Equipment name xxx |
ONBOOT=yes | Automatically activate the network card when the network service is turned on |
BOOTPROTO=dhcp or static or none | Equipment working mode |
IPADDR = | IP address |
PREFIX = | Subnet mask |
NETMASK= | It's also a subnet mask. Just select one from the above |
NAME= | Interface name |
Two IPS are configured on one piece (mult ip le can be configured, but too many are unnecessary)
After saving and exiting vim, you also need to reload the network
4, Gateway settings
Add temporary gateway
ip route add default via ip
Set global gateway
vim /etc/sysconfig/network
-
The experiment requires two virtual hosts, in which westosa sets up a dual network card as a router and westosb sets up a single network card
vim /etc/sysconfig/nrtwork-scripts
Reload the classic configuration
Use the ping command to see if the ip address is set correctly
The real machine is 172.25.254.72
westosa has two ip addresses:
172.25.254.100
1.1.1.100
westosb ip: 1.1.1.200
Use westosa to ping the real machine and westosb respectively. After ok, proceed to the next step
Supplement: configure the gateway with the specified IP effective
That is, it only works for one network card, such as ens3
Modify the / etc / sysconfig / network scripts / ifcfg-ens3 file with vim
Add a row
After setting the gateway, the dns operation will be supplemented next time...
5, DHCP service configuration
1. Configure dhcp service on westosa
Then modify dhcpd.conf with vim
Do not delete line 36 later
- Enable dhcp service
2. Test on test host westosb
Modify the network configuration file and change the way to obtain ip to dhcp
Obtained ip 172.25.254.129
6, Bridge configuration
To be added...