ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【Linux】解决由于 network和 NetworkManager不兼容,导致的网络服务错误 [打印本页]

作者: 用户云卷云舒    时间: 2024-12-25 01:30
标题: 【Linux】解决由于 network和 NetworkManager不兼容,导致的网络服务错误
今天实验启动在虚拟机中启动一些中间件环境(用docker管理),使用ssh连接虚拟机,却始终无法连接

我猜疑是不是虚拟机的ip地址改变了,但是之前我的虚拟机ip已经在 /etc/sysconfig/network-scripts 目次下,创建了对应的局域网网卡设置ifcfg-ens33。
通过ipconfig,可以看到,这里并没有ens33,前三个都是docker网桥接口的名称,每个docker网络都会创建一个对应的虚拟网桥接口。


  1. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
  2.    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  3.    inet 127.0.0.1/8 scope host lo
  4.    valid_lft forever preferred_lft forever
  5.    inet6 ::1/128 scope host
  6.    valid_lft forever preferred_lft forever
  7. 2: ens33: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
  8.    link/ether 00:0c:29:d7:b5:4c brd ff:ff:ff:ff:ff:ff
  9. 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
  10.    link/ether 52:54:00:b0:a8:63 brd ff:ff:ff:ff:ff:ff
  11.    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
  12.    valid_lft forever preferred_lft forever
  13. 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
  14.    link/ether 52:54:00:b0:a8:63 brd ff:ff:ff:ff:ff:ff
  15. 5: br-04540592dade: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
  16.    link/ether 02:42:d0:bf:51:92 brd ff:ff:ff:ff:ff:ff
  17.    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-04540592dade
  18.    valid_lft forever preferred_lft forever
  19. 6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
  20.    link/ether 02:42:1a:43:91:f2 brd ff:ff:ff:ff:ff:ff
  21.    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
  22.    valid_lft forever preferred_lft forever
  23. 7: br-f64a3536172d: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
  24.    link/ether 02:42:7b:6f:d6:49 brd ff:ff:ff:ff:ff:ff
  25.    inet 172.20.0.1/16 brd 172.20.255.255 scope global br-f64a3536172d
  26.    valid_lft forever preferred_lft forever
复制代码

  1. 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
  2.    link/ether 00:0c:29:d7:b5:4c brd ff:ff:ff:ff:ff:ff
  3.    inet6 fe80::20c:29ff:fed7:b54c/64 scope link
复制代码
此时 ens33 的状态为 up,说明正常启用。
但是启动 network服务 systemctl start network 仍然失败 (Active:failed),



查看虚拟机ip,显示ens33 状态为 UP,但是未分配ip地址
  1. ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  2.    inet6 fe80::20c:29ff:fed7:b54c prefixlen 64 scopeid 0x20<link>
  3.    ether 00:0c:29:d7:b5:4c txqueuelen 1000 (Ethernet)
  4.    RX packets 0 bytes 0 (0.0 B)
  5.    RX errors 0 dropped 0 overruns 0 frame 0
  6.    TX packets 8 bytes 656 (656.0 B)
  7.    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
复制代码
我再次检查了/etc/sysconfig/network-scripts/ifcfg-ens33,设置没有问题
  1. TYPE="Ethernet"
  2. PROXY_METHOD="none"
  3. BROWSER_ONLY="no"
  4. BOOTPROTO="static"
  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="ens33"
  13. UUID="5be4b2fe-675f-4bb6-83cf-e3f358b3652b"
  14. DEVICE="ens33"
  15. ONBOOT="yes"
  16. #IP地址
  17. IPADDR=192.168.72.100
  18. #网关
  19. GATEWAY=192.168.72.2
  20. #域名解析器
  21. DNS1=192.168.72.2
复制代码

  1. ip link set ens33 up
  2. ip addr add 192.168.72.100/24 dev ens33                # 设置 ip 为 192.168.72.100,子网掩码为 255.255.255.0
  3. ip route add default via 192.168.72.2                # 网关为 192.168.72.2
复制代码

这是一种暂时的解决方案,当我重启虚拟机时,network 服务再次 failed




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4