Ubuntu18.04 修改IP地址、查看網關、防火牆


1. Ubuntu18.04 修改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:
        enp0s3:
            addresses: [192.168.33.34/24]
            gateway4: 192.168.33.1
            dhcp4: no
       optional: no
       nameservers:
        addresses: [114.114.114.114,192.168.0.1]       version:
2

運行 sudo netplan apply 使配置生效,通過 ifconfig 查看ip是否配置成功

2. 查看網關

route -n
netstat -r

3. 防火牆開啟/關閉

ufw enable
ufw disable

 


免責聲明!

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



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