一、网卡配置参数
此配置在云上也适用
centos配置
[root@test-AA-01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE="Ethernet"
BOOTPROTO="static" #静态配置
IPV4_FAILURE_FATAL="no"
DEVICE="eth0" # 设备名字
ONBOOT="yes" # 设备重启就配置
IPADDR=10.0.0.1 # 地址
GATEWAY=10.0.0.125 # 网关
NETMASK=255.255.255.0 # 子网掩码
DNS=8.8.8.8 # dns解析也可以在 /etc/resolv.conf配置
ubuntu18.04配置
#第一步:配置网卡
root@test-AA-02:~# cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
eth0:
dhcp4: no
addresses: [10.0.0.5/24]
gateway4: 10.0.0.125
nameservers:
addresses: [8.8.8.8] # dns配置
version: 2
# 第二步:应用网卡信息
sudo netplan apply