安装虚拟机
准备工作
先安装 VMware
下载好 Linux 镜像,这边使用的 CentOS 7
配置 Linux 环境
首先尝试 ping 百度能不能 ping 通
ping www.baidu.com
发现返回指令
ping www.baidu.com: Name or services not known
查看 ip 地址
ip addr
先在 VMware 中找到分配的网卡
到系统配置目录配置网络
cd /etc/sysconfig/network-scripts/
一般默认第一个就是你电脑的网卡,我这边是 ifcfg-ens33
vi ifcfg-ens33
修改配置信息并保存退出
# 需要修改的配置
BOOTPROTO=static #将dhcp修改为静态IP地址
ONBOOT=yes
# 需要添加配置
# 设置IP地址
IPADDR0=192.168.175.100
# 设置子网掩码
PREFIXO0=24
# 设置网关
GATEWAY0=192.168.175.2
# 设置主DNS
DNS1=8.8.8.8
# 设置备DNS
DNS2=114.114.114.114
修改完配置后要重启网络系统
service network restart
然后测试是否已经可以连上网络
ping www.baidu.com
如果 ping 成功了就说明已经可以连上网络了
可以查看此时的 ip 地址
ip addr
安装常用命令
安装vim命令
yum -y install vim*
安装telnet命令
yum -y install telnet-server
yum -y install telnet
防火墙常用命令
- 启动 ->
systemctl start firewalld
- 关闭 ->
systemctl stop firewalld
- 查看状态 ->
systemctl status firewalld
- 开机禁用 ->
systemctl disable firewalld
- 开机启用 ->
systemctl enable firewalld
- 查看所有打开的端口 ->
firewall-cmd --zone=public --list-ports
- 打开一个端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
- 关闭一个端口 ->
firewall-cmd --zone= public --remove-port=80/tcp --permanent
设置时间同步
yum install -y ntp // 安装ntp服务
systemctl enable ntpd // 开机启动服务
systemctl start ntpd // 启动服务
timedatectl set-timezone Asia/Shanghai // 更改时区
timedatectl set-ntp yes // 启用ntp同步
ntpq -p // 同步时间
date -R // 查看时间