网卡配置参数

本文介绍了如何在CentOS和Ubuntu 18.04云服务器上进行网络配置。对于CentOS,配置文件为`/etc/sysconfig/network-scripts/ifcfg-eth0`,包括设置静态IP、网关和DNS。而在Ubuntu中,使用`netplan`配置,通过`50-cloud-init.yaml`文件设定网络参数,并使用`netplan apply`应用配置。
摘要由CSDN通过智能技术生成

一、网卡配置参数
此配置在云上也适用

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值