The Linux command line permanently modifies the IP address, Gateway, and DNS. 1. modify the IP address first, check the number and name of your host Nic. the related information is in/etc/sysconfig/network-scripts. As you can see, I have two Nics. The first is an Ethernet physical Nic with No. 0. if you have multiple NICs, the numbers are 0, 1, 2, and 3 ...; the second Eni is a back-to-ring Eni, which generally does not need to be set.
The Linux command line permanently modifies the IP address, Gateway, and DNS.
1. modify the IP address
First, check the number and name of your host Nic. the related information is under/etc/sysconfig/network-scripts.
As you can see, I have two Nics. The first is an Ethernet physical Nic with No. 0. if you have multiple NICs, the numbers are 0, 1, 2, and 3 ...; the second Eni is a back-to-ring Eni, which generally does not need to be set.
Use vim to edit the Nic you need to set the IP address, here I can only modify the ifcfg-eth0, see the figure, not much explanation, the previous status is set to DHCP when writing.
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 # Nic name
BOOTPROTO = static # Method for Obtaining ip addresses (static/dhcp/bootp)
HWADDR = 00: 0C: 29: B5: B2: 69 # MAC address
IPADDR = 12.168.1.5 # IP address
NETMASK = 255.255.255.0 # subnet mask
NETWORK = 192.168.1.0 # NETWORK address
BROADCAST = 192.168.0.255 # BROADCAST address
NBOOT = yes # Start the device
2. modify the Gateway
Vim/etc/sysconfig/network
Add a Gateway
GATEWAY = 192.168.1.1
3. modify DNS
Vim/etc/resolv. conf
Add DNS information.
Nameserver 192.168.1.1
4. Reload Network Configuration
/Etc/init. d/network restart