The static IP setting of Linux system

Take the following network configuration as an example:
IP address: 192.168.13.100
Subnet mask: 255.255.240.0
Default gateway: 192.168.0.2
Preferred DNS server: 114.114.114.114
Backup DBS server: 8.8.8.8 1

  1. Virtual machine network settings

Fill in the subnet IP: change the last digit of the default gateway to 0 and
fill in the subnet mask
Insert picture description here
Insert picture description here

NAT settings: set the gateway IP
Insert picture description here

Two, CentOS system network settings execute ifconfig command:
view the current network configuration
Insert picture description here

View the network: ls /etc/sysconfig/network-scripts/
Modify the configuration file:
vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=“Ethernet”
BOOTPROTO=“static”
DEFROUTE=“yes”
PEERDNS=“yes”
PEERROUTES="yes"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_table-
GENensacy="Us" GENensacy="Us
" 4f9f557a-60ff-43d4-82b9-807500dfcc4f"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.13.100
NETMASK=255.255.240.0
GATEWAY=192.168.0.2
DNS1=114.114.114.114
NM_CONTROLLED=no
Save after modification.
Disable the firewall: systemctl stop firewalld.service
systemctl disable firewalld.service
View the firewall status: systemctl status firewalld
Restart the network service: service network restart or systemctl restart network or restart the system: reboot
(currently everyone does not have a network,
so ping can’t work) for testing : Ping www.baidu.com

Guess you like

Origin blog.csdn.net/qq_2662385590/article/details/107545995