OS static IP setup steps


1. Confirm that the network cable is connected;


2.Confirm the connection status of the network card, command: ip a to view the network card name:


Command: ethtool eno1 Check the connection status of the network card:


3. Set a static IP address for a connected network card


CentOS

Edit the profile of the network card (please select the network card according to the actual situation)vim /etc/sysconfig/network-scripts/ifcfg-eno1


Modify parameters (other parameters do not need to be modified):

BOOTPROTO=static

ONBOOT=yes


Add parameters:

IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1
DNS2=192.168.1.2


Save profile. Restart network: systemctl restart network.service



Ubuntu(18.04)


Edit profile: sudo vim /etc/netplan/01-network-manager-all.yaml


Add content:

network:

    version: 2

    renderer: networkd

    ethernets:

        eno1:

            dhcp4: no

            dhcp6: no

            addresses: [192.168.1.10/24]

            gateway4: 192.168.1.1

            nameservers:

                addresses: [192.168.1.1,192.168.1.2]


Tips: If there is something after the colon, there needs to be a space after the colon.


Save profile. Make the network configuration effective: sudo netplan apply