配置网络

  • 在烧完机后,一般在/etc/sysconfig/network-scripts下的ifcfg开头文件中配置或者修改网关和DNS
  • 如:

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 #网卡设备名称
ONBOOT=yes #启动时是否激活 yes | no
BOOTPROTO=static #协议类型 dhcp bootp none
IPADDR=20.2.45.40 #网络IP地址
NETMASK=255.255.255.0 #网络子网地址
GATEWAY=20.2.45.1 #网关地址
BROADCAST=192.168.1.255 #广播地址
HWADDR=00:0C:29:FE:1A:09 #网卡MAC地址
TYPE=Ethernet #网卡类型为以太网
[root@localhost~]# /etc/init.d/network reload #重新导入ifcfg-eth0网络配置文件
service network restart #重启网卡

  • 配置了eth0网口,但是不知道网线插哪个口是eth0

ethtool -p eth0
eth0网口会闪烁

  • 查看激活的网卡信息

ifconfig
ifconfig eth0 up/down #启动关闭网卡

  • 查看ethx网口基本设置,其中x是对应网卡的编号,如eth0、eth1

ethtool eth0
如:显示千兆网卡还是万兆网卡
image.png
是否连接
image.png

  • ssh无法连接,查看22端口

netstat -ntpl | grep 22
防火墙
Iptables -nl

  • iptables 防火墙:/etc/sysconfig/iptables
  • 查看内存

free -m

  • 查看CPU使用情况

top

  • 查看系统时间

date

  • 修改时间

date –s "2020-12-12 12:30:00"

  • 把时间写入硬件

clock -w