ubuntu修改mac地址及配置静态ip

一、修改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

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页