title: linux 常见问题总结

date: 2022-04-05

comments: true

tags: [linux, 问题总结 ]

categories:

  • [操作系统, Linux ]

linux 配置静态 IP

  1. 安装 ifconfig
  1. yum search ifconfig => ifconfig net-tools.x86_64 包中
  2. sudo yum install net-tools.x86_64
  1. 查看 IP 信息
  1. ifconfig / ip addr # 查看IP 和子网掩码
  2. enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  3. inet 192.168.1.222 netmask 255.255.255.0 broadcast 192.168.1.255
  4. inet6 fe80::c597:178c:e00f:9029 prefixlen 64 scopeid 0x20<link>
  5. ether 08:00:27:50:18:58 txqueuelen 1000 (Ethernet)
  6. RX packets 4306 bytes 313127 (305.7 KiB)
  7. RX errors 0 dropped 0 overruns 0 frame 0
  8. TX packets 1243 bytes 225826 (220.5 KiB)
  9. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  10. route -n # 查看网关 GATEWAY
  11. [root@localhost etc]# route -n
  12. Kernel IP routing table
  13. Destination Gateway Genmask Flags Metric Ref Use Iface
  14. 0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp0s3
  15. 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
  16. 192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
  1. 修改配置文件
  1. vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
  2. TYPE="Ethernet"
  3. PROXY_METHOD="none"
  4. BROWSER_ONLY="no"
  5. DEFROUTE="yes"
  6. IPV4_FAILURE_FATAL="no"
  7. IPV6INIT="yes"
  8. IPV6_AUTOCONF="yes"
  9. IPV6_DEFROUTE="yes"
  10. IPV6_FAILURE_FATAL="no"
  11. IPV6_ADDR_GEN_MODE="stable-privacy"
  12. NAME="enp0s3"
  13. UUID="65348731-3dab-47ae-a462-49eb2d7e7035"
  14. DEVICE="enp0s3"
  15. ONBOOT="yes"
  16. #####静态IP改动部分开始#####
  17. # 动态 IP
  18. # BOOTPROTO="dhcp"
  19. # 静态 IP
  20. BOOTPROTO="static"
  21. IPADDR=192.168.1.222
  22. NETMASK=255.255.255.0
  23. GATEWAY=192.168.1.1
  24. DNS1=114.114.114.114
  1. 添加 DNS 服务(首选DNS服务器和备选DNS服务器)
  1. vi /etc/resolv.conf
  2. # Generated by NetworkManager
  3. search localdomain
  4. nameserver 114.114.114.114
  5. nameserver 114.114.114.115
  1. 重启网络服务
  1. service network restart
  2. systemctl network restart

Deepin 配置 SSH 远程

  1. 安装ssh服务
  1. sudo su
  2. apt-get install openssh-server
  1. 修改配置文件
  1. vi /etc/ssh/sshd_config
  2. # Authentication:
  3. LoginGraceTime 2m
  4. #PermitRootLogin prohibit-password
  5. PermitRootLogin yes # 允许 root 用户登录
  6. StrictModes yes
  1. 重启SSH服务端
  1. sudo /etc/init.d/ssh start
  2. 或者
  3. service ssh start