1、我们在虚拟机中新安装了linux,默认是无法连接网络的,这个时候,需要配置自动获取ip的网设置。
2、我们在VMware Workstatio需要配置net网络,如下图
3、进入linux系统,找到 /etc/sysconfig/network-scripts/
[root@node1 ~]# cat /etc/sysconfig/network-scripts/
ifcfg-ens33 ifdown-eth ifdown-post ifdown-Team ifup-aliases ifup-ipv6 ifup-post ifup-Team init.ipv6-global
ifcfg-lo ifdown-ippp ifdown-ppp ifdown-TeamPort ifup-bnep ifup-isdn ifup-ppp ifup-TeamPort network-functions
ifdown ifdown-ipv6 ifdown-routes ifdown-tunnel ifup-eth ifup-plip ifup-routes ifup-tunnel network-functions-ipv6
ifdown-bnep ifdown-isdn ifdown-sit ifup ifup-ippp ifup-plusb ifup-sit ifup-wireless
4、编辑ifcfg-ens33文件,不同的linux版本有所区别,进入ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=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=ens33
UUID=fd6e53bc-3038-49eb-bdd7-46db0e45e1a6
DEVICE=ens33
ONBOOT=on
在这里需要把ONBOOT改为yes
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=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=ens33
UUID=fd6e53bc-3038-49eb-bdd7-46db0e45e1a6
DEVICE=ens33
ONBOOT=yes
5、退出后,然后执行重启网络命令
service network start
6、然后可以通过ifconfig查看网络ip
[root@node1 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.42.139 netmask 255.255.255.0 broadcast 192.168.42.255
inet6 fe80::5c0f:4b80:51f6:fac prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:dd:0b:2f txqueuelen 1000 (Ethernet)
RX packets 27109 bytes 2607205 (2.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 42194 bytes 7777560 (7.4 MiB)
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 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
如果提示ifconfig不存在,需要安装工具net-tools.x86_64
yum install net-tools.x86_64
安装完成之后,就可以找到该命令了。