ubuntu修改mac地址及配置靜態ip

zmlyzml發表於2020-12-06

一、修改mac地址

1.下載net-tools

sudo apt install net-tools

2.檢視網路卡資訊

sudo ifconfig -a
ens2f0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:1b:23:bd:55:b8  txqueuelen 1000  (乙太網)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens2f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:1a:41:b5:56:b9  txqueuelen 1000  (乙太網)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enx010ec672f213: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.114.5.10  netmask 255.255.255.0  broadcast 10.114.24.255
        inet6 fe80::4539:b4ff:fe95:f257  prefixlen 64  scopeid 0x20<link>
        ether 44:39:c4:95:b2:a1  txqueuelen 1000  (乙太網)
        RX packets 53494  bytes 54911524 (54.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 38218  bytes 5053108 (5.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

3.更改mac地址

此處修改名為“enx010ec672f213”網路卡的mac地址,將其改為: 44:39:c4:95:b2:b4

sudo ifconfig enx010ec672f213 down
sudo ifconfig enx010ec672f213 hw ether 44:39:c4:95:b2:b4
sudo ifconfig enx010ec672f213 up

二、配置靜態IP

1.開啟檔案

sudo vim /etc/netplan/01-network-manager-all.yaml 

2.更改配置

以下內容為模板,將相關資訊替換為自己的,冒號後要有空格

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enx010ec672f213:   #配置的網路卡名稱
      dhcp4: no    #dhcp4關閉
      dhcp6: no    #dhcp6關閉
      addresses: [10.114.5.10/24]   #設定本機IP及掩碼
      gateway4: 10.114.5.1   #設定閘道器
      nameservers:
          addresses: [88.88.88.88]   #設定DNS 

3.應用配置資訊

sudo netplan apply

參考:參考1

相關文章