Centos7镜像安装完了发现基础的ping/ifconfig命令都是无法使用
修改网络配置
将ONBOOT=no改为yes
vi /etc/sysconfig/network-scripts/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=23b1ac4c-3d20-4d25-9c44-438c9c03845a
DEVICE=ens33
ONBOOT=yes //此处默认为NO改为yes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
修改完毕后重启网卡
service network restart
1
ping一下看看网络通不通
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (183.232.231.172) 56(84) bytes of data.
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=1 ttl=54 time=31.0 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=2 ttl=54 time=31.0 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=3 ttl=54 time=31.3 ms
1
2
3
4
5
安装基础命令依赖包
yum install net-tools.x86_64
1
安装完成后测试
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.12.150 netmask 255.255.255.0 broadcast 10.0.12.255
inet6 fe80::b62e:5bb1:b13d:7ac3 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:05:e8:85 txqueuelen 1000 (Ethernet)
RX packets 8919 bytes 11085873 (10.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3773 bytes 273515 (267.1 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 332 bytes 28808 (28.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 332 bytes 28808 (28.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
基础命令正常使用后解决ssh连接的问题
1.查看开放端口
[root@localhost ~]# firewall-cmd --list-ports
1
2.如果没有开放22端口需开放22ssh端口
firewall-cmd --zone=public --add-port=22/tcp --permanent
1
3.重启防火墙
firewall-cmd --reload
1
4.修改虚拟机为桥接模式
注:修改桥接模式将虚拟机IP通过本机桥接外网则虚拟机和本机IP网段保持一直,可以通过ssh连接
1
5.通过Xshell等ssh连接虚拟机
ifconfig查看虚拟机IP
通过ssh连接此IP
1
2
总结
A 修改网络配置能够联网
B 安装基础命令依赖
C 开放相应端口,如需ssh则开启22
D 更改虚拟机为桥接模式IP网段保持一致
E 连接虚拟机
————————————————
版权声明:本文为CSDN博主「一条金枪鱼」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43867700/article/details/89356979