The article directories

  • 1. Linux network configuration schematic diagram
    • 1.1 Draw a schematic diagram to help you understand
  • 2. View the network IP address and gateway
    • 2.1 Viewing the Virtual Network Editor and Changing the IP address
    • 2.2 Viewing gateway Information
    • 2.3 Checking VMnet8 Network Configuration in Windows (ipconfif Command)
    • 2.4 Viewing the Linux Network Configuration Ifconfig
  • 3. Ping to test the network connectivity between hosts
    • 3.1 Basic Syntax
    • 3.2 Application Examples
  • 4. Configure the Linux network environment
    • 4.1 The first method (automatic acquisition) :
    • 4.2 Second Method (Specifying an IP Address)
  • 5. Set the mapping between the host name and hosts
    • 5.1 Setting hosts Mapping
  • 6. Analysis of host name resolution (Hosts and DNS)

1. Linux network configuration schematic diagram

1.1 Draw a schematic diagram to help you understand

2. View the network IP address and gateway

2.1 Viewing the Virtual Network Editor and Changing the IP address

2.2 Viewing gateway Information

2.3 Checking VMnet8 Network Configuration in Windows (ipconfif Command)

2.4 Viewing the Linux Network Configuration Ifconfig

3. Ping to test the network connectivity between hosts

3.1 Basic Syntax

  • Ping Destination Host(Function description: Test whether the current server can connect to the destination host)

3.2 Application Examples

  • Test whether the current server can connect to Baidu
ping www.baidu.com
Copy the code

4. Configure the Linux network environment

4.1 The first method (automatic acquisition) :

  • Note: After login, through the interface to set automatically obtain IP, features: Linux will automatically obtain IP after starting, the disadvantage is that each automatically obtain IP address may be different

4.2 Second Method (Specifying an IP Address)

  • Modify the configuration file directly to specify the IP address, and can connect to the Internet (recommended by the programmer)
  • The editorvi /etc/sysconfig/network-scripts/ifcfg-ens33
  • The IP address must be static. For example, the IP address is192.168.200.13
  • ifcfg-ens33Document describing

DEVICE=eth0 # HWADDR=00:0C:2x:6x:0x:xx #MAC address TYPE=Ethernet # UUID= 926a57BA-92C6-4231-bacb-f27e5e6a9f44 # random id
#Whether the network interface is valid when the system starts (yes/no)
ONBOOT=yes
#IP configuration method [none | static | the bootp | DHCP] (boot without the use of static assign IP protocol | | | the bootp protocol DHCP protocol)
BOOTPROTO=static
#The IP addressIPADDR = 192.168.200.130#The gatewayGATEWAY = 192.168.200.2#Domain name resolverDNS1 = 192.168.200.2Copy the code
  • Restarting the network service or the system takes effect

    service network restartreboot

5. Set the mapping between the host name and hosts

13.7.1 Setting a Host Name

  1. For easy memorization, you can set the host name for the Linux system or change the host name as required
  2. instructionhostname: View the host name

  3. Modify file in/etc/hostnameThe specified

  4. The modification takes effect after a restart

5.1 Setting hosts Mapping

  • Consider: How can you find (orping) a Linux system?
  • windows

    C:\Windows\System32\drivers\etc\hostsFile specified192.168.200.130 hostnameCan bepingtong
  • Linux in/etc/hostsThe specified192.168.200.1 hostname

6. Analysis of host name resolution (Hosts and DNS)

  • What is Hosts?

    A text file that records IP andHostnameMapping between (host name)
  • DNS, that is,Domain Name SystemDomain name System (DNS) is a distributed database on the Internet that maps domain names to IP addresses
  • Application example: The user typed in the browserwww.baidu.com
  1. The browser first checks whether the domain name resolves the IP address in the browser cache, and then invokes the IP address to complete the resolution. If not, check the DNS parser cache and return the IP directly to complete the resolution. These two caches can be thought of as local parser caches
  2. Generally speaking, when a computer successfully visits a website for the first time, the browser or operating system will cache its IP address (DNS resolution record) for a certain period of time. For example, enter a value in the CMD window
ipconfig /displaydns //DNS domain name resolution cache
ipconfig /flushdns // Manually clear DNS cache
Copy the code

  1. If no mapping is found in the local parser cache, check whether the corresponding domain name IP mapping is configured in the hosts file in the system. If yes, complete the parsing and return to the host.
  2. If no CORRESPONDING IP address can be found in the local DNS cache or hosts file, resolve the domain by using the domain name service DNS
  3. Schematic diagram