1Network Configuration in Linux

1. What is IP ADDRESS

internet protocol ADDRESS ##network process address
ipv4 internet protocol version 4
2x32
ip is composed of 32 01s
11111110.11111110.11111110.11111110 = 254.254.254.254

2. Subnet mask

It is used to divide the network area. The number on the ip corresponding to the bit of the subnet mask that is not 0 indicates the network bit of this ip
The number corresponding to the 0 bit of the subnet mask is the host bit of the ip
The network bits represent the network area (like a real-life postal address)
The host bit represents a host in the network area (that is, a specific person within this postal address range)

Three, ip communication judgment

The network bits are consistent, and the two IP s with inconsistent host bits can communicate directly
172.25.254.1/24 24=255.255.255.0
172.25.254.2/24
172.25.0.1/16

4. Temporary management network card

1. Related commands

ip a		##View ip information
ifconfig	##View ip information


ping		#Check if the network is smooth
ping -c 1	#Stop after ping 1 times
ping -w 1	#stop after one second
ping -c1 -w1 ip		##ping 1 times and wait 1 second


ifconfig		##View or configure network interfaces
ifconfig		##Check
ifconfig device ip/24	##set up
ifconfig device down	##closure
ifconfig device up		##turn on


ip addr		##Detect or configure network interface
ip addr show	##detect
ip addr add ip/24 dev device		##set device ip
ip addr del dev ens160 ip/24		##delete

2. Experiment: Temporarily manage the network card


Five, permanent management network card

To make sure the NetworkManager service is turned on

1.nm-connection-editor graphically manages the network

2. Graphical configuration network in nmtui text mode


3.nmcli command to set the network

nmcli 	#NetworkManager must be enabled
[root@localhost Desktop]# nmcli device connect enp1s0		#Start the network card enp1s0
[root@localhost Desktop]# nmcli device disconnect enp1s0		#Turn off the network card enp1s0
[root@localhost Desktop]# nmcli device show enp1s0		#View network card information
[root@localhost Desktop]# nmcli device status		#View NIC service interface information
[root@localhost Desktop]# nmcli connection show #View link
[root@localhost Desktop]# nmcli connection up westosa 	#open link
[root@localhost Desktop]# nmcli connection down  westosa		#close link
[root@localhost Desktop]# nmcli connection delete westosa 	#remove link
[root@localhost Desktop]#nmcli connection add type ethernet ifname enp1s0 con-name ens3 ipv4.method manual ipv4.addresses 172.25.254.100/24		##Add links, one-to-one correspondence with graphical operation methods

[root@localhost Desktop]# nmcli connection modify westosa ipv4.addresses 172.25.254.200/24	#Edit link

4. Set up the network by managing the network profile

Network configuration directory: cd /etc/sysconfig/network-scripts/
Naming rules for network configuration files:
ifcfg-xxx	#It must start with ifcfg, followed by random, usually the name of the network card
DEVICE=enp1s0			#device name
BOOTPROTO=none|dhcp|static		#How the device works
IPPADDR=172.25.254.100				#ip address
NETMASK1=255.255.255.0			#subnet mask
IPPADDR2=172.25.254.150			#second ip address
PREFIX2=24									#Subnet mask of the second IP address
ONBOOT=yes								#Automatic word or network card when network service is turned on
NAME=westos								#interface name

6. Gateway configuration

1. Temporarily set the gateway and ping Baidu id by setting the host as the router


2. Permanently set the gateway and use the gateway and routing to ping hosts on different network segments

[root@localhost network-scripts]# vim /etc/sysconfig/network	#Global gateway, valid for all NICs that do not have a gateway set
GATEWAY=172.25.254.73
[root@localhost network-scripts]# vim /etc/sysconfig/network-scripts/ifcfg-enp1s0	
GATEWAY1=172.25.254.73	#When there are multiple IPs set in the network card, specify which IP takes effect
[root@localhost network-scripts]# route -n View gateway

Configure the experimental environment: two hosts, one host with dual network cards westos acts as a router,
A single NIC westoslinux host


7. dns

1. Configure the experimental environment

2. Detailed explanation of dns

Why can the real machine access Baidu directly through the domain name (www.baidu.com), while the virtual machine can only be accessed through ip, mainly because of address resolution

Geocoding

The system operator is sensitive to characters. The system network communication needs to pass the number of ip address. When the operator enters the URL www.baidu.com, this URL is not an IP address that can be communicated.
Therefore, it is necessary to turn www.baidu.com into the ip address of the Baidu server in the system. This process is called address resolution.

> dns(domain name server)==Domain Name Resolution Service
> > Resolution is to turn the domain name into a point to the website space IP,A service that allows people to easily access a website through a registered domain name.
> > IP An address is a numerical address that identifies a site on a network i,In order to facilitate memory, use the domain name instead IP The address represents the site address. Domain name resolution is the domain name to IP Address translation process. Domain name resolution work by DNS The server is done.

(1) Local analysis

(2) dns points to the file

Since the resolution of the domain name is done by the DNS server, here are some well-known DNS: Smart dns:114.114.114.114.114
Google's dns:8.8.8.8 You can also search for the nearest DNS server IP on Baidu

/etc/resolv.conf: The file pointed to by dns.

Eight, DHCP service configuration

1. Configure dhcp service on westosa

install dncp service



2. Test on the test host westosb


Nine, the configuration of the bridge




Tags: Linux network server

Posted by swissmant on Thu, 05 May 2022 19:51:10 +0300