Linux主機名和網(wǎng)卡名修改

網(wǎng)卡設(shè)備的命名過程:
第一步:
udev, 輔助工具程序/lib/udev/rename_device
/usr/lib/udev/rules.d/60-net.rules
第二步:
biosdevname 會根據(jù)/usr/lib/udev/rules.d/71biosdevname.rules
第三步:
通過檢測網(wǎng)絡(luò)接口設(shè)備,根據(jù)/usr/lib/udev/rules.d/75-net-description
ID_NET_NAME_ONBOARD
ID_NET_NAME_SLOT
ID_NET_NAME_PATH

Centos6

網(wǎng)絡(luò)接口識別并命名相關(guān)的udev配置文件:
[root@centos6 ~]#cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?", ATTR{address}=="00:0c:29:23:71:94", ATTR{type}=="1", KERNEL=="eth", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?", ATTR{address}=="00:0c:29:23:71:9e", ATTR{type}=="1", KERNEL=="eth", NAME="eth1"
[root@centos6 ~]#
通過修改配置文件,可以修改網(wǎng)卡名稱

Centos7

采用傳統(tǒng)命名方式
使用傳統(tǒng)命名方式:
(1) 編輯/etc/default/grub配置文件
GRUB_CMDLINE_LINUX="rhgb quiet net.ifnames=0"
sed -r 's/(quiet)/\1 net.ifnames=0/' /etc/default/grub
或直接修改/boot/grub2/grub.cfg ?
(2) 為grub2生成其配置文件
grub2-mkconfig -o /etc/grub2.cfg
(3) 重啟系統(tǒng)

CentOS 7網(wǎng)絡(luò)配置工具
CentOS7主機名
配置文件:/etc/hostname 默認沒有此文件,通過DNS反向解析獲取主機名,主機名默認為:localhost.localdomain
顯示主機名信息
hostname hostnamectl status
設(shè)置主機名
hostnamectl set-hostname centos7.magedu.com
刪除文件/etc/hostname,恢復(fù)主機名localhost.localdomain
CentOS 7網(wǎng)絡(luò)配置工具
圖形工具:nm-connection-editor
字符配置tui工具:nmtui

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容