Ubuntu 24.04 VMware裡面設定靜態ip上網

西江月明發表於2024-08-30

1.VMware裡面設定網路為橋接模式

image
image

2.Ubuntu裡面檢查網路卡名稱

[~] ip addr                                                                    
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:62:df:8f brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.122.128/24 metric 100 brd 192.168.122.255 scope global dynamic ens33
       valid_lft 1691sec preferred_lft 1691sec
    inet6 fe80::20c:29ff:fe62:df8f/64 scope link 
       valid_lft forever preferred_lft forever

image
閘道器:192.168.122.255

3.編輯Ubuntu24的網路配置檔案,路徑:/etc/netplan/

[/] cd /etc/netplan/                                                           
[netplan] ls                                                                   
50-cloud-init.yaml
[netplan] vim 50-cloud-init.yaml                                               
[netplan] sudo su                                                              
[sudo] password for planz: 
zooz# vim /etc/netplan/50-cloud-init.yaml 

切換到root使用者,編輯網路配置檔案

[~] sudo su                                                                    
[sudo] password for planz: 
zooz# vim /etc/netplan/50-cloud-init.yaml 

image

4.編輯完成儲存檔案後,執行重啟網路

zooz# sudo netplan apply

至此測試新的地址是否能連通即可...

相關文章