Centos7--13. Network Configuration

1. Linux network configuration diagram (including virtual machines)

Our current network configuration uses NAT
1

2. Check the IP network and gateway

View Virtual Network Editor 2.1

In the upper left corner of the virtual machine [Workstations] - "[Edit] -" [Virtual Network Editor]
2

2.2 modify the IP address (IP modify virtual networks)

image 3

View Gateway 2.3

Figure 4

2.4 Viewing windows environment VMnet8 network configuration (the ipconfig command)

1) See ipconfig
2) interface to view
in FIG. 5

3. ping test network connectivity between the host

3.1 The basic syntax

ping 目的主机 (功能描述:测试当前服务器是否可以连接目的主机)

3.2 Application examples

Test whether the current server can be connected to Baidu
[root@hadoop01 桌面]# ping www.baidu.com

4. Linux Network Configuration

4.1 The first method (automatic acquisition)

Cons: After Linux starts automatically obtain IP, resulting in a time automatically obtain an IP address may be different. This does not apply to the server to do, because our IP server needs to be fixed.
Image 6

4.2 The second method (designated fixed IP)

Instructions
directly modify the configuration file to specify the IP, and may be connected to external networks (recommended programmer),

  1. IP management master file stored in / etc / sysconfig / network-scripts / directory
    view the file folder:
# ls /etc/sysconfig/network-scripts/
ifcfg-eno1  ifdown-bnep  ifdown-ippp  ifdown-post    ifdown-sit       ifdown-tunnel  ifup-bnep  ifup-ippp  ifup-plip   ifup-ppp     ifup-Team      ifup-wireless      network-functions-ipv6
ifcfg-lo    ifdown-eth   ifdown-ipv6  ifdown-ppp     ifdown-Team      ifup           ifup-eth   ifup-ipv6  ifup-plusb  ifup-routes  ifup-TeamPort  init.ipv6-global
ifdown      ifdown-ib    ifdown-isdn  ifdown-routes  ifdown-TeamPort  ifup-aliases   ifup-ib    ifup-isdn  ifup-post   ifup-sit     ifup-tunnel    network-functions
  1. CentOS defaults to the first file to the primary configuration ifcfg-eno1; # each machine may be different, subject to display the
    view ENOl configuration:
# cat /etc/sysconfig/network-scripts/ifcfg-eno1 
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno1
UUID=ea4bbbab-1804-46df-b8f9-1451e5a710fc
DEVICE=eno1
ONBOOT=no
  1. The main changes identified as follows
    # vi /etc/sysconfig/network-scripts/ifcfg-eno1

  2. Further into the INSERT operations using the editing i
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno1
UUID=ea4bbbab-1804-46df-b8f9-1451e5a710fc
DEVICE=eno1
ONBOOT=yes
IPADDR=192.168.1.45
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
DNS1=192.168.1.1

Here follows :( IP gateway DNS1, depend on your actual network modifications, in which the same gateway and DNS1)

BOOTPROTO=static                  #使用static配置
ONBOOT=yes                        #开机启用本配置
IPADDR=192.168.1.45               #静态IP
GATEWAY=192.168.1.1               #默认网关
NETMASK=255.255.255.0             #子网掩码
DNS1=192.168.1.1                  #DNS配置

After modifying press [Esc] and then [shift +: [Enter] wq!]

  1. Network Service Restart
    service network restart

  2. View static IP
    ip addr 或 ifconfig

  3. Restart the system
    can automatically discover network connection is successful, a ping 192.168.1.52 (the actual IP network here based on their PCs connected) can also be used
    ping www.baidu.com

Guess you like

Origin www.cnblogs.com/zwxo1/p/11421245.html