一、查看网络IP和网关
1.查看虚拟机
在VMware的编辑中找到虚拟网络编辑器查看
在windows环境下,进入网络连接内VM8的属性中的网络协议版本4中进行查看
2.查看当前网络的ip地址
3.ping 测试主机之间网络连通性
在虚拟机中输入如下指令,如果出现该界面,则网络连通
在windows环境下输入如下ping + 虚拟机名,如果出现该界面,则网络连通
4.修改IP地址
在linux终端输入该指令,得到如下界面后,更改IP地址
更改后执行service network restart指令重启网络,更改成功
修改IP地址可能遇到的问题
a.物理机能ping通虚拟机,但是虚拟机ping不通物理机,一般都是因为物理机的防火墙问题,把防火墙关闭就行
b.虚拟机能Ping通物理机,但是虚拟机Ping不通外网,一般都是因为DNS的设置有问题
c.虚拟机Ping www.baidu.com 显示域名未知等信息,一般查看GATEWAY和DNS设置是否正确
d.如果你修改了windows主机的vmnet8的ip需要重启电脑
e.如果以上全部设置完还是不行,需要关闭NetworkManager服务
systemctl stop NetworkManager 关闭
systemctl disable NetworkManager 禁用
f.如果检查发现 systemctl status network 有问题 需要检查ifcfg-ens33
5.修改主机名称
6.修改hosts映射文件
在linux系统中,进入该指令,将一下内容添加即可
在windows系统中,在C:\Windows\System32\drivers\etc路径下找到hosts文件,将上述内容加入到该文件中即可。
7.systemctl用法
systemctl start | stop | restart | status 服务名
(1)查看网络服务的状态
[root@hadoop100 桌面]# systemctl status network
(2)停止网络服务
[root@hadoop100 桌面]# systemctl stop network
(3)启动网络服务
[root@hadoop100 桌面]# systemctl start network
(4)重启网络服务
[root@hadoop100 桌面]# systemctl restart network
systemctl list-unit-files (功能描述:查看服务开机启动状态)
systemctl disable service_name (功能描述:关掉指定服务的自动启动)
systemctl enable service_name (功能描述:开启指定服务的自动启动)
关闭防火墙
1. 临时关闭防火墙
(1)查看防火墙状态
[root@hadoop100桌面]# systemctl status firewalld
(2)临时关闭防火墙
[root@hadoop100桌面]# systemctl stop firewalld
2.开机启动时关闭防火墙
(1)查看防火墙开机启动状态
[root@hadoop100桌面]# systemctl enable firewalld.service
(2)设置开机时关闭防火墙
[root@hadoop100桌面]# systemctl disable firewalld.service
(3)查看服务是否开机自启
[root@hadoop100桌面]# systemctl is-enabled firewalld.service
disabled 表示开机不自启
enabled 表示开机自启
关机重启命令
正确的关机流程为:sync > shutdown > reboot > halt
(1)sync (功能描述:将数据由内存同步到硬盘中)
(2)halt (功能描述:关闭系统,等同于shutdown -h now 和 poweroff)
(3)reboot (功能描述:就是重启,等同于 shutdown -r now)
(4)shutdown [选项] 时间
选项 | 功能 |
-h | -h=halt关机 |
-r | -r=reboot重启 |
now | 立刻关机 |
时间 | 等待多久后关机(时间单位是分钟)。 |
实际操作
(1)将数据由内存同步到硬盘中
[root@hadoop100桌面]#sync
(2)重启
[root@hadoop100桌面]# reboot
(3)关机
[root@hadoop100桌面]#halt
(4)计算机将在1分钟后关机,并且会显示在登录用户的当前屏幕中
[root@hadoop100桌面]#shutdown -h 1 ‘This server will shutdown after 1 mins’
(5)立马关机(等同于 halt)
[root@hadoop100桌面]# shutdown -h now
(6)系统立马重启(等同于 reboot)
[root@hadoop100桌面]# shutdown -r now