Meditation operating system ip configuration file interfaces does not match the actual IP

Go to the network card configuration directory

cd /etc/netwrok/
vim interfaces

NIC configuration information

source /etc/network/interfaces.d/*.conf
auto lo
iface lo inet loopback
    allow-hotplug eth0

auto eth2
allow-hotplug eth2
iface eth2 inet static
    address 100.100.100.1
    netmask 255.255.0.0

The above configuration file is a complete configuration file. To add an IP address, just add the following configuration information.

auto eth2
allow-hotplug eth2
iface eth2 inet static
    address 100.100.100.1
    netmask 255.255.0.0

After adding the IP address, restart the network card

sudo service networking restart

The above is reproduced from: 

Meditation Linux operating system, add IP address to network card_lemmon_tree's blog-CSDN blog_linux meditation system configuration ip address

 However, in practical application, it is found that the above ip address is configured in this file, and it is found that the ip address does not correspond to the actual one after booting.

reason:

The ip setting information is also configured in the /etc/rc.local file, so during the host startup process, the interfaces file should be run first, and then the shell command in rc.local should be run.

for n in `seq 0 4`;
do
  ifconfig eth$n 192.168.$n.222
done
ifconfig eth5 193.100.33.33

Guess you like

Origin blog.csdn.net/modi000/article/details/123471511