實(shí)驗(yàn)環(huán)境:RHEL 7
虛擬機(jī)安裝RHEL7之后執(zhí)行ip add發(fā)現(xiàn)只有一個(gè)網(wǎng)卡lo進(jìn)入/ect/sysconfig/network-scripts/目錄發(fā)現(xiàn)只有ifcfg-lo沒有eth0,隨后自己配置了一個(gè)eth0發(fā)現(xiàn)并不可行,本人查閱資料解決了此問題祈匙,方案如下
關(guān)閉RHEL7,進(jìn)入安裝目錄找到*.vmx文件天揖,用編輯器打開夺欲,在最后一行添加ethernet0.virtualDev="e1000",啟動(dòng)虛擬機(jī)今膊,再次執(zhí)行ip addr發(fā)現(xiàn)多了一張網(wǎng)卡的信息些阅,復(fù)制其中出現(xiàn)的MAC的地址
[root@system1 ~]#ip addr
1: lo: <LOOPBACK,UP,LOWER UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 000:0000:000:00
inet 127.0.0.1/8 scope host to
valid_lft forever preferred_lft forever
inet6::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state up qlen 1000
link/ether 00:Oc:29:97:9h:39 brd ff:ff:ff:ff:ff:ff
進(jìn)入/ect/sysconfig/network-scripts/目錄發(fā)現(xiàn)只有ifcfg-lo,沒有eno16777736的配置文件便自己編寫一個(gè)
[root@system1 ~]#vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
ONBOOT=yes
USERCTL=no
PEERDNS=yes
TYPE= Ethernet
DEVICE=eno16777736#//(此處的是網(wǎng)卡設(shè)備的序號(hào)也就是ip addr中看到的網(wǎng)卡名稱)
HWADDR=00:0c:29:64:c2:5f#此處可以不添加,根據(jù)自己機(jī)器而定
BOOTPROTO=dhcp
可是在重啟網(wǎng)卡時(shí)
[root@system1 ~]#systemctl restart network
Restarting network (via systemctl): Job for network.service failed. See'systemctl status network.service'
and 'journalctl -xn' for details.
根據(jù)上面的提示斑唬,執(zhí)行“systemctl status network.service”輸出以下的類似信息:
[root@system1 ~]# systemctl status network.service
network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network)
Active: failed (Result: exit-code) since 二 2018-04-17 17:39:19 CST; 5min ago
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists
4月 17 17:39:19 localhost.localdomain network[2784]: RTNETLINK answers: File exists
4月 17 17:39:19 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1
4月 17 17:39:19 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
4月 17 17:39:19 localhost.localdomain systemd[1]: Unit network.service entered failed state.
解決的辦法(由于centos7中沒有70-persistent-net.rules這個(gè)文件市埋,復(fù)制出來的虛擬機(jī)需要修改mac地址),就是修改mac地址。
將之前復(fù)制的MAC地址寫入配置文件中恕刘,執(zhí)行systemctl restart network 就成功了