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

 

 

 

 

 

 

 

 

 

 

 

查看網絡硬件:

lspci |grep Eth

 

 

 

 

 

 

 

 

 

 

 

 

 

 

相關資料:

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

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

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM