異世界


2023年8月9日 星期三

ubuntu 更改網口名稱

 


#######################

# ubuntu 更改網口名稱

# (於 192.168.32.128 測試)

#

# 參考網頁 : https://caloskao.org/ubuntu-nic-rename/

#

#######################


#====================

# 1.查詢網路介面名稱

user@arkime01:~$ ip link


#--------------------------------------------------------------------------------------------------------------

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000

    link/ether 00:0c:29:c9:af:f6 brd ff:ff:ff:ff:ff:ff

    altname enp2s1



#================================================================================

#2. 新增規則檔案 : /etc/udev/rules.d/70-persistent-net-generator.rules

#  我們可以藉由 Linux udev 將網路卡名稱更改成自己喜歡的名稱

#

#  a) 首先,使用 sudo nano /etc/udev/rules.d/70-persistent-net-generator.rules 指令建立一個規則檔案,

#     將新名稱與網路卡 MAC 位址寫入 (MAC 在前面的 ip link 指令有列出 )

#

user@arkime01:~$ sudo nano /etc/udev/rules.d/70-persistent-net-generator.rules


## 格式: SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="網路卡MAC位址", NAME="網路卡新名稱" 

#---------------------------------------------------------------------------------

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:0c:29:c9:af:f6", NAME="eth0"

#---------------------------------------------------------------------------------





#======================================================

# 3. 編輯設定檔 /etc/netplan/00-installer-config.yaml

#

user@arkime01:~$ sudo nano /etc/netplan/00-installer-config.yaml


## 原檔案內容 , 須修改網口名稱

#---------------------------------------------------

# This is the network config written by 'subiquity'

network:

  ethernets:

    ens33:

      dhcp4: true

  version: 2

  

  

## 更改後內容

#---------------------------------------------------

# This is the network config written by 'subiquity'

network:

  ethernets:

    eth0:

      dhcp4: true

  version: 2

  

  

#############################

# 4. 重啟系統

user@arkime01:~$ sudo rebooot



#############################

#5 測試

user@arkime01:~$ ip link




#############################

#5 測試並套用網路介面設定檔

  

user@arkime01:~$ ip link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000

    link/ether 00:0c:29:c9:af:f6 brd ff:ff:ff:ff:ff:ff

    altname enp2s1

    altname ens33


 

 

  

  

  

  

#############################

#

# DELL 750 紀錄

#  

#############################

  GNU nano 6.2    00-installer-config.yaml

# This is the network config written by 'subiquity'

network:

  ethernets:

    eno12399np0:

      dhcp4: false

      addresses: [192.168.17.31/16]

    eno12409np1:

      dhcp4: true

    eno8303:

      dhcp4: false

      addresses: [172.16.17.31/16]

    eno8403:

      dhcp4: true

  version: 2



沒有留言:

張貼留言