一、CentOS 6与7更改主机名

  1. 1.桥接模式:这种模式下,虚拟机和物理机连的是同一个网络,虚拟机和物理机是并列关系,地位是相当的。
  2. 比如,你家有路由器,那么你的电脑和你的手机同时连接这个路由器提供的Wi-Fi,那么它们的关系就是这种模式。
  3. 2.NAT模式:这种模式下,物理机会充当一个“路由器”的角色,虚拟机要想上网,必须经过物理机,那物理机如果不能上网,虚拟机也就不能上网了。之所以说这种模式兼容性最好,是因为物理机的网络环境变化时,虚拟机的网络并不会有影响,比如,上班时你把物理机连接在公司的网络环境中,下班后又把物理机连接在你家的路由器上。你公司的网段有可能和你家的网段是不同的。桥接模式下,虚拟机和物理机一样,都要自动获取IP才可以上网,而做实验的时候,是需要把虚拟机设置为静态IP的,这样就导致虚拟机网络不稳定。而设置为NAT模式,虚拟机的网络并不需要依赖你公司的网络环境或者你家的网络环境。
  4. 3.仅主机模式:这种模式下,相当于拿一根网线直连了物理机和虚拟机。

1、centos6 更改

临时配置

hostname 查看主机名

hostname 主机名

hostname server1

永久配置

##修改配置文件,配置文件在/etc/sysconfig/network

2、centos7更改

临时配置

hostname 主机名

hostname server1

永久配置

##修改配置文件,配置文件在/etc/hostname
或者
hostnamectl set-hostname 要修改的主机名

二、CentOS 6与7关闭防火墙和selinux

1、Centos6.5:防火墙


## 临时关闭:
##关闭:iptables
[root@node2 ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@node2 ~]# service iptables status
iptables: Firewall is not running.
[root@node2 ~]#
## 永久关闭: chkconfig iptables off
## 开机自动关闭:
[root@node2 ~]# chkconfig --list|grep iptables
iptables 0:off  1:off  2:on  3:on  4:on  5:on  6:off
[root@node2 ~]# chkconfig iptables off
## 关闭selinux:
[root@node2 ~]# getenforce
Enforcing
[root@node2 ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@node2 ~]# setenforce 0  临时变成警告模式
[root@node2 ~]# getenforce
Permissive
##永久关闭
[root@node2 ~]# cat /etc/selinux/config
...
SELINUX=disabled  //关闭selinux,下次开机生效
...

2、centos7:防火墙

#chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。
#chkconfig 在centos6中有用 
#centos7用  
#systemctl list-unit-files
#systemctl list-unit-files |grep firewalld
[root@server129 ~]# chkconfig --list |grep iptables

注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
      如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
      欲查看对特定 target 启用的服务请执行
      'systemctl list-dependencies [target]'。
[root@server129 ~]# systemctl list-unit-files |grep firewalld
firewalld.service
##systemctl status/stop/restart firewalld.service  防火墙状态

[root@server129 ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 六 2020-09-05 17:08:18 CST; 6h ago
 Main PID: 945 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─945 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

9月 06 01:01:16 localhost.localdomain systemd[1]: Starting firewalld - dynami...
9月 05 17:08:18 localhost.localdomain systemd[1]: Started firewalld - dynamic...
Hint: Some lines were ellipsized, use -l to show in full.

#临时关闭firewalld  systemctl stop firewalld.service

[root@server129 ~]# systemctl stop firewalld.service
[root@server129 ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 六 2020-09-05 23:21:25 CST; 3s ago
  Process: 945 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 945 (code=exited, status=0/SUCCESS)

9月 06 01:01:16 localhost.localdomain systemd[1]: Starting firewalld - dynami...
9月 05 17:08:18 localhost.localdomain systemd[1]: Started firewalld - dynamic...
9月 05 23:21:24 server129 systemd[1]: Stopping firewalld - dynamic firewall.....
9月 05 23:21:25 server129 systemd[1]: Stopped firewalld - dynamic firewall ...n.
Hint: Some lines were ellipsized, use -l to show in full.


#关闭firewalld 防火墙   开机自启动

[root@server129 ~]# systemctl list-unit-files |grep firewalld
firewalld.service                           enabled
[root@server129 ~]# ^C
[root@server129 ~]# systemctl list-unit-files |grep iptbles
[root@server129 ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@server129 ~]# systemctl list-unit-files |grep firewalld
firewalld.service                           disabled
[root@server129 ~]#

三、配置yum源

1、本地yum源

# 挂载一个iso 镜像, 把光盘挂载到一个目录/mnt下,然后进入/etc/yum.reps.d/目录下,创建一个以 .repo结尾的文件,
#df -h 查看文件系统磁盘使用情况
[root@server129 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  3.6G   14G   21% /
devtmpfs                 474M     0  474M    0% /dev
tmpfs                    489M  156K  489M    1% /dev/shm
tmpfs                    489M  7.1M  482M    2% /run
tmpfs                    489M     0  489M    0% /sys/fs/cgroup
/dev/sda1                497M  158M  340M   32% /boot
tmpfs                     98M   16K   98M    1% /run/user/1000
/dev/sr0                 4.1G  4.1G     0  100% /run/media/wuhe/CentOS 7 x86_64
tmpfs                     98M     0   98M    0% /run/user/0
# mount 用于挂载Linux文件外的系统  -o ro 用唯读方式挂载

[root@server129 ~]# mount -o ro /dev/sr0 /mnt
[root@server129 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   18G  3.6G   14G   21% /
devtmpfs                 474M     0  474M    0% /dev
tmpfs                    489M  156K  489M    1% /dev/shm
tmpfs                    489M  7.1M  482M    2% /run
tmpfs                    489M     0  489M    0% /sys/fs/cgroup
/dev/sda1                497M  158M  340M   32% /boot
tmpfs                     98M   16K   98M    1% /run/user/1000
/dev/sr0                 4.1G  4.1G     0  100% /mnt
tmpfs   

[root@server129 /]# cd mnt/
[root@server129 mnt]# ls
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL
[root@server129 mnt]# cd /etc/yum.repos.d/
[root@server129 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@server129 yum.repos.d]# mv *.repo repo_backup/
mv: 目标"repo_backup/" 不是目录
[root@server129 yum.repos.d]# mkdir repo_backup
[root@server129 yum.repos.d]# mv *.repo repo_backup/
[root@server129 yum.repos.d]# ls
repo_backup
[root@server129 yum.repos.d]# vim local.repo
[base]
name=local yum
baseurl=file:///mnt
gpgcheck=0
enabled=1

Centos 6 和 Centos 7比较 - 图1

#配置完后紧接着使用命令
#yum clean all 清空本地的yum源缓存
#yum repolist  重新生成元数据 列出仓库里面的软件包
#yum grouplist 查看yum源的列表并生成相应的元数据缓存到本地 或者 #yum  makecache  重新生成缓存


[root@server129 repo_backup]# yum clean all
已加载插件:fastestmirror, langpacks
没有已启用的源。
执行 "yum repolist all" 查看您拥有的源。
您可以用 yum-config-manager --enable <源名> 来启用源
[root@server129 repo_backup]# yum list
已加载插件:fastestmirror, langpacks
已安装的软件包
GConf2.x86_64                           3.2.6-8.el7                     @anaconda
[root@server128 mnt]# yum grouplist
已加载插件:fastestmirror, langpacks
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
可用的环境分组:
   最小安装
   基础设施服务器
   计算节点
   文件及打印服务器
   基本网页服务器
   虚拟化主机
   带 GUI 的服务器
   GNOME 桌面
   KDE Plasma Workspaces
   开发及生成工作站
可用组:
   传统 UNIX 兼容性
   兼容性程序库
   图形管理工具
   安全性工具
   开发工具
   控制台互联网工具
   智能卡支持
   科学记数法支持
   系统管理
   系统管理工具
完成

补充

下面两条命令分别通过设备名和挂载点卸载文件系统,同时输出详细信息:

# umount -v /dev/sda1          通过设备名卸载  
/dev/sda1 umounted  
# umount -v /mnt/mymount/      通过挂载点卸载  
/tmp/diskboot.img umounted

2、外网yum源

https://blog.csdn.net/xiaojin21cen/article/details/84726193

https://www.cnblogs.com/fengdejiyixx/p/10952672.html?tdsourcetag=s_pcqq_aiomsg

四、抓包工具

1、wireshark工具

#配置好yum源后安装wireshark工具
[root@server129 yum.repos.d]# yum list|grep wireshark
wireshark.i686                              1.10.14-24.el7             base
wireshark.x86_64                            1.10.14-24.el7             base
wireshark-devel.i686                        1.10.14-24.el7             base
wireshark-devel.x86_64                      1.10.14-24.el7             base
wireshark-gnome.x86_64                      1.10.14-24.el7             base
[root@server129 yum.repos.d]# yum -y install wireshark.x86_64 wireshark-gnome.x86_64
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 wireshark.x86_64.0.1.10.14-24.el7 将被 安装
--> 正在处理依赖关系 libsmi.so.2()(64bit),它被软件包 wireshark-1.10.14-24.el7.x86_64 需要
---> 软件包 wireshark-gnome.x86_64.0.1.10.14-24.el7 将被 安装
--> 正在检查事务
---> 软件包 libsmi.x86_64.0.0.4.8-13.el7 将被 安装
--> 解决依赖关系完成
.
.
.


已安装:
  wireshark.x86_64 0:1.10.14-24.el7    wireshark-gnome.x86_64 0:1.10.14-24.el7

作为依赖被安装:
  libsmi.x86_64 0:0.4.8-13.el7

完毕!
#确定是否装好
[root@server129 yum.repos.d]# rpm -q wireshark
wireshark-1.10.14-24.el7.x86_64
[root@server129 yum.repos.d]# rpm -q wireshark-gnome
wireshark-gnome-1.10.14-24.el7.x86_64

五、补充 rpm -qf

https://blog.csdn.net/qq_41116956/article/details/82801115

rpm -qf xxx 查询文件或命令属于哪个安装包

Centos 6 和 Centos 7比较 - 图2

Centos 6 和 Centos 7比较 - 图3

Centos 6 和 Centos 7比较 - 图4

六、yum 和epel

https://www.cnblogs.com/weiguang/p/12040067.html

https://blog.csdn.net/u011341352/article/details/82943871

https://blog.csdn.net/qq_41709494/article/details/89067136

https://blog.csdn.net/xiaojin21cen/article/details/84726193

https://blog.51cto.com/11970509/2104170

https://www.cnblogs.com/weiguang/p/12040067.html

https://developer.aliyun.com/mirror/epel?spm=a2c6h.13651102.0.0.52081b11HaM4lU

https://developer.aliyun.com/mirror/epel?spm=a2c6h.13651102.0.0.52081b11HaM4lU