EverKB

Knowledge Base Ever

在CentOS7上修改網卡名稱為eth0

2019-11-12 17:53:29

標籤: CentOS7, eth0, network interface,

在安裝完CentOS7以後,網卡名稱變成了enp0s3,而不是CentOS以前版本中的eth0。 eth0命名方式的好處是,當網卡出現故障更換後,網卡名稱仍保持不變,無需重新命名,可以直接替換硬件。新的命名方式的好處是自動基於固件、拓撲結構、位置信息來確定。

如果我們希望把網卡命名方式修改為eth0的形式,可以進行以下操作。
進入網卡配置文件目錄,調整網卡名稱
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-enp0s3 ifcfg-eth0
調整網卡的配置信息,修改NAME=eth0,修改DEVICE=eth0,如下:
[root@localhost network-scripts]# cat ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=1a3d4251-a3dc-ea48-6e77-234evb23d9476
DEVICE=eth0
ONBOOT=yes
DNS1=8.8.8.8
IPADDR=192.168.0.100
PREFIX=24
GATEWAY=192.168.0.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no
修改grub文件

在GRUB_CMDLINE_LINUX行加入net.ifnames=0 biosdevname=0,參數之間使用空格隔開,插入的位置隨意,不同機器可能略有不同。
[root@localhost network-scripts]# cat /etc/sysconfig/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g'/etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=128M rhgb net.ifnames=0 biosdevname=0 quiet"
GRUB_DISABLE_RECOVERY="true"
重新生成grub啟動菜單
[root@localhost network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg

標籤

CentOS7 CentOS PHP Linux Python3 Python MySQL MariaDB YUM JavaScript CSS Redis MySQL8 caching_sha2_password HTML mysql_native_password PHP7 CURLFille horiz-align node.js ShadowsocksR vertical-align BarManager exec mb_substr PyCharm SUBDATE date add IntelliJIDEA PEAR SOCKS5 Proxy Server WebStorm Chrome find remi Tag du jQuery PHP5.5 src Apache cURL hide nginx Shadowsocks-Python V2Ray availability eth0 MariaDB10.4 PostgreSQL sub folder date Install MongoDB pdo_sqlsrv SOCKS5 Web Server File Upload mssql-tools register_shutdown_function Symfony DevExpress JetBrain php-fpm sqlsrv Zend Framework ADDDATE height network interface Shadowsocks-Libev unixODBC-devel Aura error_get_last Port 80 string data INDENTIFIED BY password policy requirements SOCKS Web Development Fedora Media Writer msodbcsql Redis5 SVN Deepin jemalloc SQLAlchemy absolute convert FuelPHP mysqlclient Shadowsocks toggle at-symbol Error Control Operator margin PHPUnit Framework ss5.passwd daemon process IIS password SOCKET vps center Fatal Errors MongoDB4 sudoers DATE_SUB Phalcon SQL Server 2017 WiFi .htaccess Compiling PHP frequency conflict set_error_handler TestCase apr Elasticsearch7.3 PHPUnit ss5.conf daemon HTTP particles.js Slim Vincent Garreau Failed to build these modules: _uuid MongoDB Sudo DATE_ADD ip command pg_bha.conf SQL Server width Compiling Apache Frameworks MySQL-python scrollbar Tcp BBR Apache2.4 Elasticsearch libpython3.7m.so.1.0 PHPStorm ss5-3.8.9 CURLOPT_POSTFIELDS NodeJs show VIM Bluetooth Failed to build these modules: _ctypes Minimal ISO substr date sub INTERVAL PECL SQL Date Funcitons Wi-Fi CodeIgniter font-size root Tag Cloud dual network interfaces Laravel ss5 apache httpd