项目场景:
测试tcpdump工具需要安装telnet验证tcpdump语法。
tcpdump -i ens33 -c 10 src host 源IP and dst host 目标IP and dst port 目标端口
安装telnet:
rpm -qa telnet-server
yum -y install telnet-server
rpm -qa telnet
yum -y install telnet
service xinetd restart
若 Failed to restart xinetd: Unit not found
yum -y install xinetd
若Failed to restart xinetd.service: Unit not found
yum install telnet-server
cd /etc/xinetd.d/
vim telnet
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
重启
service xinetd restart
netstat -tnl |grep 23
若在上面的安装过程中出现:
Error downloading packages:
1:telnet-server-0.17-66.el7.x86_64: [Errno 256] No more mirrors to try.
1:telnet-0.17-66.el7.x86_64: [Errno 256] No more mirrors to try.
2:xinetd-2.3.15-14.el7.x86_64: [Errno 256] No more mirrors to try.
等,则需要更换镜像源
更换镜像源:
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
问题描述
安装telnet过程中需要更新镜像源,在安装telnet后使用wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
中出现”未知的名称或服务“,之后又出现了”网络不可达“问题。
原因分析:
解决方案:
- 排查DNS配置:
vim /etc/resolv.conf
,发现少了网关配置
配置好了之后又出现”网络不可达“
nameserver 网关IP
2. 接着看路由表
route -n
,发现少了默认网关的配置,
加上route add default gw 网关ip
同时,网卡的配置/etc/sysconfig/network-scripts/ifcfg-ens33
也要写上DNS1和GATEWAY(均是网关IP),这样重启(reboot)就不会失效
解决!
route命令参考:
route命令参考1
route命令参考2
网络不可达问题排除思路:
参考1