Ubuntu18.04 server 双网卡,一个设置为静态IP, 一个设置为动态IP

操作目的如题:

 

修改网络配置文件:

sudo vim /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:
        enp7s0:
            dhcp4: true
            nameservers:
                addresses:
                - 202.118.66.6
                search: []
            optional: true


        enp8s0:
            addresses:
            - 192.168.11.66/24
            gateway4: 192.168.11.254
            nameservers:
                addresses:
                - 202.118.66.6
                search: []
            optional: true


    version: 2

 

 

 

 

编辑完后,执行命令:

sudo netplan apply

 

 

 

 

其中, 网卡  enp7s0  设置为动态获取ip, 网卡 enp8s0  设置为静态ip 。

 

 

 

  

 

 

 

==================================================================

 

 

 

常用的相关命令:

 

 

 

查看网络设备配置:

ip  a

 

Ubuntu18.04 server   双网卡,一个设置为静态IP, 一个设置为动态IP

 

 

 

 

 

 

 

 

 

 

查看网络硬件:

lspci |grep Eth

 

Ubuntu18.04 server   双网卡,一个设置为静态IP, 一个设置为动态IP

 

 

 

 

 

 

 

 

 

 

 

 

 

相关资料:

https://www.cnblogs.com/devilmaycry812839668/p/13994054.html

https://www.cnblogs.com/devilmaycry812839668/p/10254971.html

https://blog.csdn.net/songyuequan/article/details/89437405

 

Ubuntu18.04 server 双网卡,一个设置为静态IP, 一个设置为动态IP

上一篇:Linux自有服务


下一篇:VMware_Centos7_安装