当前位置:   article > 正文

麒麟操作系统修改网卡配置文件与ssh连接失败解决_麒麟系统网卡配置文件

麒麟系统网卡配置文件

目录

一、修改网卡配置文件

1、介绍

2、编写网卡配置文件

3、配置DNS

4、重启服务,启动配置

二、解决ssh远程失败问题

1.取消DNS反向解析

2.修改身份验证 

三.修改超时时间


一、修改网卡配置文件

1、介绍

麒麟系统安装后默认为桌面图标设置网络,且为图形设置方式,对于非图形界面与修改、批量设置时候很不友好;可以编写对应的网卡配置文件解决此问题

2、编写网卡配置文件

  1. root@kylin:~# ifconfig #查看网卡名
  2. root@kylin:~# vim /etc/network/interfaces #修改网卡配置文件
  3. # interfaces(5) file used by ifup(8) and ifdown(8)
  4. auto lo
  5. iface lo inet loopback
  6. auto enaphyt4i0 #开机自动生效
  7. iface enaphyt4i0 inet static #配置类型为静态
  8. address 192.168.2.98 #配置IP地址
  9. netmask 255.255.255.0 #配置子网掩码
  10. gateway 192.168.2.254 #配置网关

3、配置DNS

  1. root@kylin:~# sed -i "/#DNS=/ c DNS=114.114.114.114" /etc/systemd/resolved.conf
  2. #修改DNS配置文件,地址可以根据需要自己替换DNS服务器地址
  1. 修改后文件如下:
  2. root@kylin:~# cat /etc/systemd/resolved.conf
  3. # This file is part of systemd.
  4. #
  5. # systemd is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # Entries in this file show the compile time defaults.
  11. # You can change settings by editing this file.
  12. # Defaults can be restored by simply deleting this file.
  13. #
  14. # See resolved.conf(5) for details
  15. [Resolve]
  16. DNS=114.114.114.114
  17. #FallbackDNS=
  18. #Domains=
  19. #LLMNR=no
  20. #MulticastDNS=no
  21. #DNSSEC=allow-downgrade
  22. #DNSOverTLS=no
  23. #Cache=yes
  24. #DNSStubListener=yes
  25. #ReadEtcHosts=yes

4、重启服务,启动配置

  1. root@kylin:~# systemctl daemon-reload #重新加载配置
  2. root@kylin:~# systemctl restart systemd-resolved #重启服务
  3. 然后cat /etc/resolv.conf会发现DNS信息已经更新进去
  4. root@kylin:~# systemctl restart networking #重启网卡服务

二、解决ssh远程失败问题

ssh登录某些服务器,会发生等待时间过长问题才能到输入密码阶段,或者XShell远程时提示22端口连接失败等问题;可以修改对应远程客户端配置解决此问题,有两个方法

1.取消DNS反向解析

  1. root@kylin:~# sed -i '/#UseDNS/ s/#//' /etc/ssh/sshd_config #取消DNS解析
  2. root@kylin:~# systemctl restart sshd #重启服务使配置生效

2.修改身份验证 

  1. root@kylin:~# sed -i "/[^#]...GSSAPI/ s/yes/no/" /etc/ssh/ssh_config
  2. root@kylin:~# systemctl restart ssh #重启服务

三.修改超时时间

默认超时连接时间比较短,这是出去安全考虑,但是长时间使用的用户比较麻烦,每次都要重新连接,可以修改特定参数时间

  1. root@kylin:~# sed -i "/Client/ s/0/10/" /etc/ssh/sshd_config #修改超时时间
  2. root@kylin:~# systemctl restart sshd #重启服务使配置生效

这样超过10s没有动作的情况下,sshd服务才会中断连接

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号