copy别人的虚拟机,应该如何配置网络

首先,copy过来后,输入

[hadoop@hadoop000 ~]$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 48  bytes 6000 (5.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 6000 (5.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:0a:50:ad  txqueuelen 1000  (Ethernet)
        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

[hadoop@hadoop000 ~]$ cd /etc/sysconfig/network-scripts/
[hadoop@hadoop000 network-scripts]$ ls
ifcfg-eth0                ifdown-ib    ifdown-ppp       ifdown-tunnel  ifup-ib    ifup-plusb   ifup-Team         network-functions
ifcfg-Wired_connection_1  ifdown-ippp  ifdown-routes    ifup           ifup-ippp  ifup-post    ifup-TeamPort     network-functions-ipv6
ifdown                    ifdown-ipv6  ifdown-sit       ifup-aliases   ifup-ipv6  ifup-ppp     ifup-tunnel
ifdown-bnep               ifdown-isdn  ifdown-Team      ifup-bnep      ifup-isdn  ifup-routes  ifup-wireless
ifdown-eth                ifdown-post  ifdown-TeamPort  ifup-eth       ifup-plip  ifup-sit     init.ipv6-global
[hadoop@hadoop000 network-scripts]$ 
如上所示:看到ip为127.0.0.1,说明肯定上不了网了。

首先进入如上所写的目录中,删除掉ifcfg-lo如果有这个的话删掉,没有就继续。

[hadoop@hadoop000 network-scripts]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:0c:29:9f:4c:ca brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:0a:50:ad brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:0a:50:ad brd ff:ff:ff:ff:ff:ff
[hadoop@hadoop000 network-scripts]$ 
复制出来mac地址00:0c:29:9f:4c:ca,上面我标红的那块。

之后输入:

[hadoop@hadoop000 network-scripts]$ vi ifcfg-eth0 

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
#BOOTPROTO=static
HWADDR=00:0c:29:9f:4c:ca
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=ad169432-7822-4c84-beff-b4bd41b3606f
DEVICE=eth0
#ONBOOT=yes

NM_CONTROLLER=no
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.175.175
NETMASK=255.255.255.0
GATEWAY=192.168.175.1 #这个虚拟机有个编辑-》虚拟网络编辑器-》查看(这个必须和windows网关一样)
DNS1=8.8.8.8
DNS2=192.168.1.1或者8.8.4.4
~                      

修改下我标红的HWADDR那块,把复制的mac地址复制上去换成自己的。

修改下我标红的IPADDR那块,看下自己主机的ip网段,写上去换成自己的。

修改下我标红的GATEWAY那块,看下自己网关是多少,写上去换成自己的。

之后看下

[hadoop@hadoop000 network-scripts]$ cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
HOSTNAME=hadoop000
[hadoop@hadoop000 network-scripts]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 192.168.1.1
[hadoop@hadoop000 network-scripts]$

是否正确,是否是自己的。

注意:关闭防火墙,永久关闭(指的是liunx的防火墙)

之后右击虚拟机中你的镜像点设置,有一个网络适配器,过去配置一下,我这边是自定义:VMnet8(NAT模式)

重启一下ok啦(reboot)

©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页