赞
踩
1、物理网卡共享给虚拟网卡
2、查看虚拟网卡详细信息
IPv4地址默认是192.168.137.1
,dns默认自动获取,可以按需修改
1、切换root用户
2、修改网络配置文件
/etc/sysconfig/network-scripts
目录下的ifg-eth0
文件
eth0 是网卡名称,可以通过 ifconfig 查看
[root@linux ~]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.137.12 netmask 255.255.255.0 broadcast 192.168.137.255 inet6 fe80::5aa6:fd21:e7a7:fd43 prefixlen 64 scopeid 0x20<link> ether 00:15:5d:00:df:00 txqueuelen 1000 (Ethernet) RX packets 69 bytes 8649 (8.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 80 bytes 9229 (9.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 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 1000 (Local Loopback) RX packets 32 bytes 2592 (2.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 32 bytes 2592 (2.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@linux ~]#
[root@linux ~]#
[root@linux ~]# cd /etc/sysconfig/network-scripts
[root@linux network-scripts]# vi ifcfg-eth0
3、修改配置
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static #静态IP;动态的话,要改成 dhcp 才行 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=f5e37a10-2h5s-we24-58se-370b7bf24509 DEVICE=eth0 #设备名称(网卡名称),要跟文件名称对应 ONBOOT=yes #开机自启动 IPADDR=192.168.137.222 # IP 地址# 必设置 GATEWAY=192.168.137.1 # 网关地址# 必设置 NETWORK=192.168.137.1 # 该网段的第一个 IP# 可以不设置 BROADCAST=192.168.137.255 # 最后一个同网段的广播地址# 可以不设置 NETMASK=255.255.255.0 # 子网掩码# 必设置与宿主机vEthernet(nat)一致 DNS1=192.168.137.1 # 必设置 可以跟网关一致
主要修改的配置:
BOOTPROTO=static #静态IP;动态的话,要改成 dhcp 才行
ONBOOT=yes #开机自启动
IPADDR=192.168.137.222 # IP 地址# 必设置
GATEWAY=192.168.137.1 # 网关地址# 必设置
NETMASK=255.255.255.0 # 子网掩码# 必设置与宿主机vEthernet(nat)一致
DNS1=192.168.137.1 # 必设置 可以跟网关一致
3、重启虚拟机网络服务
[root@linux network-scripts]# service network restart
4、查看IP地址
[root@linux network-scripts]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.137.222 netmask 255.255.255.0 broadcast 192.168.137.255
inet6 fe80::5aa6:fd21:e7a7:fd43 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:00:df:00 txqueuelen 1000 (Ethernet)
RX packets 813 bytes 67953 (66.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 548 bytes 67909 (66.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
设置成功
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。