目录

Centos环境配置

1、telnet安装配置

1.1、检查是否安装telnet

1.2、安装telnet

1.3、查看是否安装xinetd (若安装则不安装)

1.4、安装xinetd服务

1.5、开启服务

1.6、安装后检查

1.7、启动telnet和依赖的xinetd服务

1.8、查看启动状态

1.9、启动telnet命令

2、防火墙检查与配置

2.1、查看防火墙状态

2.2、停止firewall

2.3、禁止firewall开机启动

3、TFTP服务器安装配置

3.1、安装配置tftp

3.2、使用fileZilla连接tftp服务

4、剖析虚拟机网络模式

4.1、Bridged(桥接模式)

4.2、NAT(网络地址转换模式)

4.3、Host-Only(仅主机模式)

5、双网卡配置


Centos环境配置

1、telnet安装配置

1.1、检查是否安装telnet

[root@localhost ]# rpm -qa | grep telnet  

1.2、安装telnet

[root@localhost xinetd.d]# yum -y install telnet  

[root@localhost xinetd.d]# yum -y install telnet-server  

1.3、查看是否安装xinetd (若安装则不安装)

[root@localhost ~]# rpm -qa | grep xinetd 

1.4、安装xinetd服务

[root@localhost init.d]# yum -y install xinetd 

1.5、开启服务

安装telnet服务之后,默认是不开启服务,修改文件/etc/xinetd.d/telnet来开启服务:
注:如有则修改,第一次修改,此文件若不存在,可自己vim创建修改:
       修改 disable = yes 为 disable = no

[root@localhost xinetd.d]# pwd  
/etc/xinetd.d  
[root@localhost xinetd.d]# ls  
chargen-dgram  chargen-stream  daytime-dgram  daytime-stream  discard-dgram  discard-stream  echo-dgram  echo-stream  tcpmux-server  time-dgram  time-stream  
  
[root@localhost xinetd.d]# vim telnet  
[root@localhost xinetd.d]# cat telnet

修改后的telnet文件为:

# default: yes  
  
# description: The telnet server servestelnet sessions; it uses \  
  
# unencrypted username/password pairs for authentication.  
service telnet  
{  
   flags           = REUSE  
   socket_type     = stream  
   wait            = no  
user            = root  
   server          =/usr/sbin/in.telnetd  
log_on_failure  += USERID  
   disable         = no   
}

1.6、安装后检查

[root@CentOS-Slave1 xinetd.d]# rpm -qa | grep telnet  
telnet-0.17-59.el7.x86_64  
telnet-server-0.17-59.el7.x86_64  
[root@CentOS-Slave1 xinetd.d]# rpm -qa | grep xinetd  
xinetd-2.3.15-12.el7.x86_64

1.7、启动telnet和依赖的xinetd服务

在centos7之前:

$ service  xinetd restart     

或$ /etc/rc.d/init.d/xinetd  restart  

在centos7中(无xinetd的service启动项):

[root@CentOS-Slave1 xinetd.d]# service xinetd restart  
Redirecting to /bin/systemctl restart  xinetd.service  
[root@CentOS-Slave1 xinetd.d]# systemctl restart  xinetd.service

[root@CentOS-Slave1 xinetd.d]# /bin/systemctl restart  xinetd.service  

1.8、查看启动状态

[root@CentOS-Slave1 xinetd.d]# ps -ef | grep xinetd  
root      6641     1  0 23:22 ?        00:00:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid  
root      6644  5817  0 23:24 pts/3    00:00:00 grep --color=auto xinetd 
[root@localhost vsol]# netstat -tnl |grep 23
tcp6       0      0 :::23                   :::*                    LISTEN

1.9、启动telnet命令

假如以上步骤操作完成 查看23端口仍然未启动

执行以命令启动telnet

systemctl enable telnet.socket
systemctl start telnet.socket

注:root用户一般不给登录,需要创建一个普通用户进行telnet登录

创建普通用户命令

#adduser username

#passwd username

输入两次密码

2、防火墙检查与配置

其他主机telnet进来,需要先关闭centos防火墙

2.1、查看防火墙状态

#firewall-cmd --state

2.2、停止firewall

#systemctl stop firewalld.service

2.3、禁止firewall开机启动

#systemctl disable firewalld.service

3、TFTP服务器安装配置

3.1、安装配置tftp

[root@localhost ~]# yum -y install tftp
[root@localhost ~]# yum -y install tftp-server
[root@localhost ~]#vi /etc/xinetd.d/tftp
Modify  disable  to  no
[root@localhost ~]#systemctl restart xinetd.service
[root@localhost ~]#netstat -a | grep tftp
[root@localhost ~]#netstat -tunap | grep  :69

3.2、使用fileZilla连接tftp服务

用户名可以使用root

centos 运行sh centos运行环境_centos

4、剖析虚拟机网络模式

vmware为我们提供了三种网络工作模式,它们分别是:

Bridged(桥接模式)、NAT(网络地址转换模式)、Host-Only(仅主机模式)

选项栏的“编辑”下的“虚拟网络编辑器”中看到VMnet0(桥接模式)、VMnet1(仅主机模式)、VMnet8(NAT模式)

注:NAT模式与主机模式十分相似,主要不同之处即在于主机模式中宿主机不再具备NAT功能,即不再相当于虚拟机访问Internet的路由器(主机模式虚拟网络是不能连接到外部的互联网的,虚拟机之间形成的虚拟网络是一个全封闭的网络,和外部的唯一联系就是虚拟机能够和主机进行通信)

[root@localhost vsol]# ls /etc/sysconfig/network-scripts/
ifcfg-ens33
ifcfg-lo     ifdown-isdn    ifdown-TeamPort  ifup-ippp   ifup-ppp       ifup-wireless
ifdown       ifdown-post    ifdown-tunnel    ifup-ipv6   ifup-routes    init.ipv6-global
ifdown-bnep  ifdown-ppp     ifup             ifup-isdn   ifup-sit       network-functions
ifdown-eth   ifdown-routes  ifup-aliases     ifup-plip   ifup-Team      network-functions-ipv6
ifdown-ippp  ifdown-sit     ifup-bnep        ifup-plusb  ifup-TeamPort
[root@localhost vsol]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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=f6bb1310-2506-4a37-a11c-fd4aca2b8f5f
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.175.128
NETMASK=255.255.255.0
GATEWAY=192.168.175.2
DNS1=114.114.114.114

在window网络连接中可以看到对应的虚拟网卡

centos 运行sh centos运行环境_centos 运行sh_02

4.1、Bridged(桥接模式)

centos 运行sh centos运行环境_linux_03

centos 运行sh centos运行环境_服务器_04

4.2、NAT(网络地址转换模式)

centos 运行sh centos运行环境_centos_05

centos 运行sh centos运行环境_服务器_06

4.3、Host-Only(仅主机模式)

centos 运行sh centos运行环境_centos_07

centos 运行sh centos运行环境_centos 运行sh_08

主机模式:在此模式下所有的虚拟系统之间可以相互通信,但是虚拟系统所处的虚拟网络和宿主机所处的真实网络实际上是被隔离开的。尽管被隔离,但是在这种模式下虚拟系统和主机可以通信,相当于两台机器直接用双绞线相连,这时宿主机不再为虚拟机提供路由服务,所以虚拟机不能和外部Network进行通讯

5、双网卡配置

5.1、先将ens33配置为NAT模式,确定能通外网

5.2、再添加桥接网卡,默认通过ifconfig可以查看到新增了ens37网卡

#cd /etc/sysconfig/network-scripts/

#nmcli conn   //查看ens37的uuid 拷贝到网络配置文件中

#cp ifcfg-ens33 ifcfg-ens37

5.3、重启网络  service network restart