当前位置: 首页 > news >正文

远程控制时频繁掉线的原因

事情的起因,最近在使用远程软件进行远程控制时, 面临了一个被控端频繁掉线的问题,
出现的情况便是,每隔一段时间,被控制端就会自动掉线,大概过一段时间又会自动重新登录。

这里主要介绍笔者遇到的原因,

  1. 一个 DHCP 导致的原因;
  2. 另一个是被控端, 防火墙的原因

1. reason Dhcp 动态配置, 限制原因

  1. 按照 检查 DHCP 存在的问题;

  2. 设置 静态ip

  3. 存在多个 proile, 删除多余的 wired connection

1.1 检查 DHCP

sudo journalctl -u NetworkManager | grep -i "dhcp"

使用上面的命令, 输出当前网络中 DHCP 中的相关内容

1031 20:00:18 your_pc-Product-Name NetworkManager[921]: <info>  [1730376018.3290] dhcp4 (enp4s0): state changed unknown -> bound
1101 10:24:07 your_pc-Product-Name NetworkManager[956]: <info>  [1730427847.1301] dhcp-init: Using DHCP client 'dhclient'
1101 10:24:10 your_pc-Product-Name NetworkManager[956]: <info>  [1730427850.8423] dhcp4 (enp4s0): activation: beginning transaction (timeout in 45 seconds)
1101 10:24:10 your_pc-Product-Name NetworkManager[956]: <info>  [1730427850.8437] dhcp4 (enp4s0): dhclient started with pid 1414
1101 10:24:10 your_pc-Product-Name dhclient[1414]: DHCPREQUEST of 192.168.11.42 on enp4s0 to 255.255.255.255 port 67 (xid=0x286daeae)
1101 10:24:13 your_pc-Product-Name dhclient[1414]: DHCPREQUEST of 192.168.11.42 on enp4s0 to 255.255.255.255 port 67 (xid=0x286daeae)
1101 10:24:18 your_pc-Product-Name dhclient[1414]: DHCPREQUEST of 192.168.11.42 on enp4s0 to 255.255.255.255 port 67 (xid=0x286daeae)
1101 10:24:18 your_pc-Product-Name dhclient[1414]: DHCPACK of 192.168.11.42 from 192.168.8.1
1101 10:24:18 your_pc-Product-Name NetworkManager[956]: <info>  [1730427858.4532] dhcp4 (enp4s0):   address 192.168.11.42
1101 10:24:18 your_pc-Product-Name NetworkManager[956]: <info>  [1730427858.4532] dhcp4 (enp4s0):   plen 21 (255.255.248.0)
1101 10:24:18 your_pc-Product-Name NetworkManager[956]: <info>  [1730427858.4532] dhcp4 (enp4s0):   gateway 192.168.8.1
1101 10:24:18 your_pc-Product-Name NetworkManager[956]: <info>  [1730427858.4532] dhcp4 (enp4s0):   lease time 259200
1101 10:24:18 your_pc-Product-Name NetworkManager[956]: <info>  [1730427858.4532] dhcp4 (enp4s0):   nameserver '223.5.5.5'
1101 10:24:18 your_pc-Product-Name NetworkManager[956]: <info>  [1730427858.4532] dhcp4 (enp4s0):   nameserver '180.76.76.76'
1101 10:24:18 your_pc-Product-Name NetworkManager[956]: <info>  [1730427858.4532] dhcp4 (enp4s0): state changed unknown -> bound
1102 15:08:31 your_pc-Product-Name NetworkManager[15835]: <info>  [1730531311.9600] dhcp-init: Using DHCP client 'dhclient'
1102 15:18:48 your_pc-Product-Name NetworkManager[27091]: <info>  [1730531928.4536] dhcp-init: Using DHCP client 'dhclient'

Observations from the DHCP LogsDHCP 日志中的观察结果

  1. Repeated DHCP Requests:重复的 DHCP 请求

    • The logs show multiple instances of DHCPREQUEST and DHCPACK messages for the IP address 192.168.11.42.日志显示 IP 地址192.168.11.42DHCPREQUESTDHCPACK消息的多个实例。
    • This means that your system was continuously requesting an IP address, and the DHCP server was repeatedly assigning 192.168.11.42.这意味着您的系统不断请求 IP 地址,并且 DHCP 服务器重复分配192.168.11.42
  2. Lease Time:租赁时间

    • Each DHCP lease appears to have a lease time of 259200 seconds (3 days).每个 DHCP 租约的租约时间似乎为 259200 秒(3 天)。
    • Despite the long lease time, the system was still periodically initiating new DHCP requests. This could indicate connectivity issues or that NetworkManager was unable to retain the lease information correctly.

尽管租用时间很长,系统仍然定期发起新的 DHCP 请求。这可能表明存在连接问题或 NetworkManager 无法正确保留租约信息。

这里是由于笔者的被控机器上, 存在两个 wired Connection , 导致两者之间在切换,没有配置好, 即下面的第三种情况。

  1. Timeouts and Retries:超时和重试

    • There are messages indicating a timeout of 45 seconds before each transaction. This might suggest that the DHCP client was experiencing delays or issues maintaining a stable connection to the DHCP server.每笔交易前都会有消息指示超时 45 秒。这可能表明 DHCP 客户端在维持与 DHCP 服务器的稳定连接时遇到延迟或问题。

Likely Causes of Repeated DHCP Requests重复 DHCP 请求的可能原因

This type of log behavior can be caused by:这种类型的日志行为可能是由以下原因引起的:

  • Network Connectivity Issues: Physical or network-related issues causing temporary disconnections, prompting the system to re-request an IP address.网络连接问题:物理或网络相关问题导致暂时断开连接,促使系统重新请求 IP 地址。

  • Configuration or Conflict with DHCP Server: The DHCP server might have been experiencing issues or conflicts that resulted in it not recognizing or retaining the lease.与 DHCP 服务器的配置或冲突:DHCP 服务器可能遇到问题或冲突,导致其无法识别或保留租约。

  • NetworkManager Configuration: NetworkManager might have been attempting to reinitialize or re-authenticate the network connection, possibly due to settings or authorization issues.NetworkManager 配置:NetworkManager 可能一直在尝试重新初始化或重新验证网络连接,这可能是由于设置或授权问题造成的。

1.2 设置 静态ip

在这里插入图片描述

Step 1: Configure a Static IP Address

  1. Select “Manual” under IPv4 Method, which you’ve already done.
  2. Enter Static IP Details:
    • Addresses:
      • Address: Enter your chosen static IP (e.g., 192.xxx.11.42).
      • Netmask: Enter the subnet mask (e.g., 255.255.248.0 if you’re using a /21 subnet).
      • Gateway: Enter the IP address of your router (e.g., 192.168.8.1).
    • DNS: Enter your DNS servers (e.g., 223.5.5.5 and 180.76.76.76). Separate multiple entries with commas.
  3. Save and Apply:
    • Once you have entered the settings, click Apply.
    • Restart your network connection by disconnecting and reconnecting to apply the static IP configuration.

这是笔者在配置完 静态ip 出现的情况, 注意观察最后的内容, 仍然出现 DHCP 的相关信息,这是由于多个 Wired connection 导致的, 后续需要删除多余, 避免他们之间的切换而导致网络断线。

 sudo journalctl -u NetworkManager -f
-- Logs begin at Sun 2023-10-22 14:35:22 CST. --
1102 15:33:19 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532799.5486] settings-connection[0x56142f1a5b60,6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b]: write: successfully updated (keyfile: update /etc/NetworkManager/system-connections/Wired connection 2 (6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b,"Wired connection 2"))
1102 15:33:19 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532799.5488] audit: op="connection-update" uuid="6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b" name="Wired connection 2" args="connection.timestamp,ipv4.addresses" pid=32547 uid=1000 result="success"
1102 15:33:47 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532827.9440] settings-connection[0x56142f1a5b60,6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b]: write: successfully updated (keyfile: update /etc/NetworkManager/system-connections/Wired connection 2 (6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b,"Wired connection 2"))
1102 15:33:47 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532827.9441] audit: op="connection-update" uuid="6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b" name="Wired connection 2" args="connection.timestamp" pid=32547 uid=1000 result="success"
1102 15:35:16 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532916.1452] settings-connection[0x56142f1a5b60,6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b]: write: successfully updated (keyfile: update /etc/NetworkManager/system-connections/Wired connection 2 (6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b,"Wired connection 2"))
1102 15:35:16 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532916.1453] audit: op="connection-update" uuid="6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b" name="Wired connection 2" args="ipv4.addresses" pid=32547 uid=1000 result="success"
1102 15:35:42 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532942.4960] settings-connection[0x56142f1a5b60,6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b]: write: successfully updated (keyfile: update /etc/NetworkManager/system-connections/Wired connection 2 (6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b,"Wired connection 2"))
1102 15:35:42 your_pc-Product-Name NetworkManager[27091]: <info>  [1730532942.4962] audit: op="connection-update" uuid="6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b" name="Wired connection 2" args="connection.timestamp" pid=32547 uid=1000 result="success"
1102 15:59:07 your_pc-Product-Name NetworkManager[27091]: <info>  [1730534347.8489] settings-connection[0x56142f1a5b60,6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b]: write: successfully updated (keyfile: update /etc/NetworkManager/system-connections/Wired connection 2 (6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b,"Wired connection 2"))
1102 15:59:07 your_pc-Product-Name NetworkManager[27091]: <info>  [1730534347.8492] audit: op="connection-update" uuid="6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b" name="Wired connection 2" pid=32547 uid=1000 result="success"
1102 16:09:18 your_pc-Product-Name dhclient[1414]: DHCPREQUEST of 192.168.11.42 on enp4s0 to 192.168.8.1 port 67 (xid=0x286daeae)
1102 16:09:18 your_pc-Product-Name dhclient[1414]: DHCPACK of 192.168.11.42 from 192.168.8.1

Impact and Solution with Static IP静态IP的影响和解决方案

By switching to a static IP configuration, you removed the dependency on the DHCP server, which should:通过切换到静态 IP配置,您消除了对 DHCP 服务器的依赖,这应该:

  • Prevent Frequent IP Reassignments: Since your IP is now fixed, the system won’t need to negotiate leases with the DHCP server.防止频繁重新分配 IP :由于您的 IP 现在已固定,系统无需与 DHCP 服务器协商租约。
  • Resolve Network Stability Issues: If DHCP requests were causing connection resets or interruptions, a static IP configuration should help maintain a more stable connection.解决网络稳定性问题:如果 DHCP 请求导致连接重置或中断,静态 IP 配置应有助于维持更稳定的连接。

Next Steps下一步

  1. Monitor Connection Stability: With the static IP configuration now in place, check if the network stability has improved.监控连接稳定性:静态 IP 配置完成后,检查网络稳定性是否有所改善。

  2. Check for Disconnection Logs: If disconnections persist, examine recent logs with:检查断开连接日志:如果断开连接仍然存在,请使用以下命令检查最近的日志:

    sudo journalctl -u NetworkManager -f
    

    This may reveal any other potential causes unrelated to DHCP.这可能会揭示与 DHCP 无关的任何其他潜在原因。

In summary, based on the logs, switching to a static IP was a good choice to potentially resolve the disconnection issues related to DHCP lease reassignments. Let me know if you still experience any issues!总之,根据日志,切换到静态 IP 是解决与 DHCP 租约重新分配相关的断开连接问题的不错选择。

1.3 存在多个 proile, 删除多余的 wired connection

The log entries show that NetworkManager made a connection update for your wired connection (Wired connection 2). This update process can cause a temporary network disruption, which likely resulted in the disconnection of your remote session. Here’s an explanation of what may have happened:日志条目显示NetworkManager为您的有线连接( Wired connection 2 )进行了连接更新。此更新过程可能会导致暂时的网络中断,这可能会导致远程会话断开。以下是对可能发生的情况的解释:

Possible Reasons for the Disconnection断开连接的可能原因

  1. NetworkManager Reconfiguration:网络管理器重新配置

    • When you clicked on the network icon in the upper-right corner, it’s possible that NetworkManager initiated a re-evaluation or reconfiguration of the network settings for the active connection.当您单击右上角的网络图标时,NetworkManager 可能会启动对活动连接的网络设置的重新评估或重新配置。

    • This can happen if NetworkManager detects changes or if you manually toggle or modify the network connection in the NetworkManager GUI.

  2. Switching between Network Profiles:

    • If there are multiple profiles configured for the same network interface (like Wired connection 1 and Wired connection 2), NetworkManager might switch between them when you interact with the network menu. This can briefly disconnect the network as it applies the new profile settings.

如果为同一网络接口配置了多个配置文件(例如Wired connection 1和Wired connection 2 ),当您与网络菜单交互时,NetworkManager 可能会在它们之间切换。这可能会在应用新的配置文件设置时短暂断开网络连接。

这里是笔者 出现 断链的原因

  1. DHCP Request Despite Static IP:

    • Interestingly, the log shows a DHCPREQUEST from the dhclient, suggesting that NetworkManager tried to negotiate with the DHCP server even though you set a static IP. This can happen if NetworkManager is still managing the interface as a dynamic (DHCP) connection, possibly due to conflicting settings in the network configuration.

有趣的是,日志显示来自dhclient的DHCPREQUEST ,这表明即使您设置了静态 IP,NetworkManager 仍尝试与 DHCP 服务器进行协商。

如果 NetworkManager 仍将接口作为动态 (DHCP) 连接进行管理,则可能会发生这种情况,这可能是由于网络配置中的设置冲突造成的。

Solutions to Prevent Future Disconnections

  1. Lock the Static Configuration in NetworkManager:

    • Ensure that the static IP configuration is set directly in NetworkManager (as you have done), and avoid switching or toggling network connections unless necessary.
    • If you have more than one wired network profile, consider removing or disabling the unused profiles to avoid accidental switching.

如果您有多个有线网络配置文件,请考虑删除或禁用未使用的配置文件,以避免意外切换。

Product-Name:~$ nmcli connection show
NAME                UUID                                  TYPE      DEVICE 
Wired connection 2  6b74dc8e-b80f-3dc5-bdd6-ddb229bcf35b  ethernet  enp4s0 
HUSTEZ-Guest        f28da620-c5ea-451b-89f3-0c84e7cf7394  wifi      --     
Hello               e4642e5a-32bb-4d22-9078-cb8692ddd87c  wifi      --     
Redmi K40 Pro       34544e6a-59e4-46f2-b131-27ed2fc989e5  wifi      --     
Tenda_ch5h6U        5ba8403d-34c6-4fa9-89ea-cfef75237e0d  wifi      --     
Wired connection 1  9a2cbbe2-5dce-3a9f-9d6a-2017fe354751  ethernet  --     
hi                  639cb5c3-db57-48d5-8720-4b6f4d7289fc  wifi      --     

Explanation of the Mismatch

  • Network Profiles: NetworkManager allows you to create multiple profiles (or “connections”) for the same network interface (like enp4s0). In this case, it seems you have two profiles: Wired connection 1 and Wired connection 2.

网络配置文件: NetworkManager允许您为同一网络接口(如enp4s0 )创建多个配置文件(或“连接”)。在这种情况下,您似乎有两个配置文件:有线连接 1和有线连接 2 。

根据上面的输出结果显示, 该机器上存在两个配置, 导致他们之间在来回切换,从而导致掉线, Wired connection 1, Wired connection 2, 需要删除 冗余的那个。

  • Active Profile: According to your nmcli output, the active profile assigned to the device enp4s0 is Wired connection 2. However, when you check the details for Wired connection 1, it shows that autoconnect is enabled. This may cause conflicts as NetworkManager might try to switch between them.

活动配置文件:根据您的nmcli输出,分配给设备enp4s0活动配置文件是有线连接 2 。但是,当您检查有线连接 1的详细信息时,它显示自动连接已启用。这可能会导致冲突,因为 NetworkManager 可能会尝试在它们之间进行切换。

执行如下命令,删除冗余的

nmcli connection delete "Wired connection 1"
Connection 'Wired connection 1' (9a2cbbe2-5dce-3a9f-9d6a-2017fe354751) successfully deleted.

Recommendations

To avoid confusion and ensure only one profile is actively managing the static IP, it’s best to clean up the profiles. Here’s what you can do:

  1. Confirm the Active Profile:

    • Use nmcli to verify which profile is actively connected to enp4s0:

      nmcli device status
      
    • This will show which profile (Wired connection 1 or Wired connection 2) is currently assigned to the network interface.

  2. Delete the Unused Profile:

    • To avoid conflicts, it’s recommended to keep only one wired connection profile for enp4s0.

    • If Wired connection 2 is the profile actively connected to enp4s0 and contains the correct settings, you can delete Wired connection 1:

      nmcli connection delete "Wired connection 1"
      
  3. Verify and Reapply Static IP Settings:

    • After deleting the unused profile, go back to the NetworkManager GUI for Wired connection 2 and double-check the static IP settings under the IPv4 tab.
    • Make sure to click Apply to ensure the settings are saved and effective.
  4. Restart NetworkManager (optional):

    • After making changes, you may want to restart NetworkManager to ensure it recognizes the updated configuration:

      sudo systemctl restart NetworkManager
      
  5. Check the Configuration Again:

    • Run the following command to confirm that only one profile is active and configured with the static IP:

      nmcli connection show
      nmcli connection show "Wired connection 2"
      

Summary

  • Delete the unused profile (Wired connection 1) to avoid conflicts.
  • Keep only Wired connection 2 with your static IP settings.
  • Restart NetworkManager if needed to apply changes smoothly.

This should help maintain a stable network configuration without any interference from unused profiles.

  1. Stop DHCP Client for Static IP:

    • NetworkManager may still attempt DHCP requests if it is configured to expect a dynamic IP in certain settings. You can try explicitly setting Method to Manual in both the IPv4 and IPv6 tabs to prevent any DHCP interference.
  2. Restart NetworkManager After Setting Static IP:

    • After confirming the static IP settings, restart NetworkManager to apply changes and clear any conflicting configurations:

      sudo systemctl restart NetworkManager
      
  3. Disable Autoconfiguration (if not needed):

    • If IPv6 is not required, set IPv6 to Ignore in NetworkManager settings to avoid unnecessary updates or DHCPv6 negotiations, which can sometimes interfere with connectivity.

Summary

The disconnection was likely triggered by NetworkManager reapplying or updating the network configuration when you interacted with the network icon, causing a brief network disruption. By ensuring that only one profile is active and configured with a static IP, you should be able to reduce the likelihood of unexpected disconnections.

1.4 关于网络图标存在×号的原因

在这里插入图片描述

The appearance of the small “×” on the network icon in the upper right corner typically indicates that NetworkManager is not fully recognizing or managing the active connection, even though the network itself is working. Since your remote connection remains stable, it suggests that the static IP configuration is effectively bypassing NetworkManager’s DHCP management, allowing the connection to persist.右上角网络图标上出现小“×”通常表示NetworkManager未完全识别或管理活动连接,即使网络本身正在工作。由于您的远程连接保持稳定,这表明静态 IP 配置有效地绕过了 NetworkManager 的 DHCP 管理,从而允许连接持续存在。

Why the “×” Appears and What It Means为什么会出现“×”以及它的含义

  • Static IP Not Managed by NetworkManager: When you set a static IP manually outside of NetworkManager’s typical DHCP configuration, it may sometimes not recognize the connection as “active,” even though it’s working correctly.静态 IP 不受 NetworkManager 管理:当您在 NetworkManager 的典型 DHCP 配置之外手动设置静态 IP 时,有时可能无法将连接识别为“活动”,即使它工作正常。
  • NetworkManager Update Attempts: The log entries show connection-update messages, which likely correspond to NetworkManager trying to update or re-verify the connection settings. Since you’ve switched to a static IP, NetworkManager may see this as an unmanaged or custom configuration.NetworkManager 更新尝试:日志条目显示connection-update消息,这可能对应于 NetworkManager 尝试更新或重新验证连接设置。由于您已切换到静态 IP,NetworkManager 可能会将其视为非托管或自定义配置。

Solutions to Remove the “×” Symbol去除“×”符号的解决方法

If the network is working as expected and the only issue is the “×” symbol, you can leave it as is, as it’s more of a visual indicator than a functional issue. However, if you want to clear the symbol, here are a few things you can try:如果网络按预期工作并且唯一的问题是“×”符号,您可以保持原样,因为它更多的是一个视觉指示器而不是功能问题。但是,如果您想清除该符号,可以尝试以下几种操作:

Option 1: Set the Static IP Directly in NetworkManager选项 1:直接在 NetworkManager 中设置静态 IP
  1. Open Network Settings:打开网络设置
    • Go to Settings > Network and select your Wired Connection.转至设置 > 网络并选择您的有线连接
  2. Edit the connection settings:编辑连接设置:
    • Under the IPv4 tab, set the IP method to Manual and enter your static IP, subnet, and gateway here (like you did in the GUI interface).在IPv4选项卡下,将 IP 方法设置为手动,并在此处输入您的静态 IP、子网和网关(就像您在 GUI 界面中所做的那样)。
  3. Save the changes and reconnect:保存更改并重新连接:
    • This will allow NetworkManager to manage the static IP configuration directly.这将允许 NetworkManager 直接管理静态 IP 配置。
Option 2: Disable “Connect Automatically” for Unused Connections选项 2:禁用未使用连接的“自动连接”
  1. If you have multiple network profiles for the same network interface, disable “Connect Automatically” for profiles that you don’t use.如果同一网络接口有多个网络配置文件,请为不使用的配置文件禁用“自动连接”
  2. This can prevent NetworkManager from attempting to re-establish different configurations, which may clear up the symbol.这可以防止 NetworkManager 尝试重新建立不同的配置,这可能会清除该符号。
Option 3: Restart NetworkManager选项 3:重新启动 NetworkManager

If you want to refresh NetworkManager to see if it recognizes the connection without the “×”, restart it with:如果您想刷新 NetworkManager 以查看它是否识别不带“×”的连接,请使用以下命令重新启动它:

sudo systemctl restart NetworkManager

After restarting, check if the “×” symbol disappears.重新启动后,检查“×”符号是否消失。

Option 4: Ignore NetworkManager if Not Needed选项 4:如果不需要,则忽略 NetworkManager

If the connection is stable and the symbol doesn’t impact performance, you can ignore it. However, if you’d rather disable NetworkManager for this connection entirely, you can:如果连接稳定并且该符号不影响性能,则可以忽略它。但是,如果您希望完全禁用此连接的 NetworkManager,您可以:

  1. Stop NetworkManager for the interface:停止该接口的 NetworkManager

    sudo nmcli device disconnect <interface>
    

    Replace <interface> with your network interface name (e.g., enp4s0).将<interface>替换为您的网络接口名称(例如enp4s0 )。

  2. Configure Network Manually via Netplan (for Ubuntu):通过 Netplan 手动配置网络(对于 Ubuntu):

    • Use a netplan configuration file instead of NetworkManager to control the network settings directly.使用netplan配置文件而不是 NetworkManager 直接控制网络设置。

概括

The “×” symbol is likely a minor discrepancy between NetworkManager’s status and your static IP configuration. It shouldn’t affect the network performance, especially since your remote connection remains stable. Adjusting NetworkManager’s settings to explicitly manage the static IP (Option 1) might resolve the symbol, but if everything is working well, it can be ignored safely. Let me know if you’d like more guidance on any of these options!“×”符号可能是 NetworkManager 的状态与您的静态 IP 配置之间的微小差异。它不应该影响网络性能,特别是因为您的远程连接保持稳定。调整 NetworkManager 的设置以显式管理静态 IP(选项 1)可能会解析该符号,但如果一切正常,则可以安全地忽略它。如果您需要有关这些选项的更多指导,请告诉我!

2 防火墙, 拦截原因;

检查当前开放的端口;

sudo ufw status

If you suspect the firewall is causing frequent disconnections, you can configure ufw (Uncomplicated Firewall) to allow traffic specifically for Sunflower and other required ports.

  1. Identify the Sunflower Port:

    • From previous interactions, it appears that Sunflower uses port 5657. Confirm this in Sunflower’s settings if needed.
  2. Allow Sunflower Port through UFW:

    • Open a terminal and run the following command to allow traffic on port 5657:

      sudo ufw allow 5657
      
  3. Enable UFW (if not already enabled):

    • If UFW is not already active, enable it:

      sudo ufw enable
      
  4. Check UFW Status:

    • Verify that the rule for Sunflower is applied:

      sudo ufw status
      
    • Ensure that port 5657 is listed as allowed.

3. 介绍一下DHCP

3.1 What is a DHCP Client?什么是 DHCP 客户端?

A DHCP (Dynamic Host Configuration Protocol) client is a device or software component on a network that requests an IP address and other network settings from a DHCP server. The DHCP client’s role is to automatically configure the network settings on the device so it can communicate on the network.

DHCP(动态主机配置协议)客户端是网络上从DHCP 服务器请求 IP 地址和其他网络设置的设备或软件组件。 DHCP 客户端的作用是自动配置设备上的网络设置,以便其可以在网络上进行通信。

When a device (like a computer, smartphone, or router) connects to a network, the DHCP client communicates with the DHCP server to request network information, such as:当设备(如计算机、智能手机或路由器)连接到网络时,DHCP 客户端与 DHCP 服务器通信以请求网络信息,例如:

  • IP address: The unique address for the device on the network.IP 地址:设备在网络上的唯一地址。
  • Subnet mask: Defines the network segment.子网掩码:定义网段。
  • Gateway: The router or gateway device for network traffic.网关:网络流量的路由器或网关设备。
  • DNS servers: For resolving domain names to IP addresses.DNS 服务器:用于将域名解析为 IP 地址。

3.2 Why Does a DHCP Client Have an IP Lease Time?

DHCP客户端为什么有IP租用时间?

When a DHCP server assigns an IP address to a client, it does so for a limited time known as the lease time. This lease is like a “rental” of the IP address, which expires after a specified period. Once the lease time expires, the client must renew the lease to keep the IP address or request a new one.当 DHCP 服务器向客户端分配 IP 地址时,它会在称为租用时间的有限时间内执行此操作。这种租约就像是“租用”IP 地址,在指定期限后到期。一旦租约到期,客户端必须续订租约以保留 IP 地址或请求新的 IP 地址。

The lease time is important for several reasons:租赁时间很重要,原因如下:

  1. Efficient IP Address Management: DHCP servers can assign IPs dynamically based on current demand. If a device leaves the network, its IP will eventually be released and made available for other devices.高效的IP地址管理:DHCP服务器可以根据当前需求动态分配IP。如果设备离开网络,其 IP 最终将被释放并可供其他设备使用。
  2. Network Security: If a device is removed from the network or becomes inactive, its IP address will be recycled, which prevents old IPs from remaining indefinitely assigned to inactive devices.网络安全:如果设备从网络中删除或变为不活动状态,其 IP 地址将被回收,这可以防止旧 IP 无限期地分配给不活动设备。
  3. Allows for Reconfiguration: If network changes are made (e.g., new DNS servers or a different gateway), the lease renewal process enables clients to receive the latest configuration without manual intervention.允许重新配置:如果网络发生更改(例如,新的 DNS 服务器或不同的网关),租约续订过程使客户端能够接收最新配置,而无需手动干预。

3.3 How is DHCP Configured?DHCP 是如何配置的?

DHCP configuration generally involves setting up the DHCP server to provide network information to clients. On the client side, configuration is minimal because the client will automatically request settings from the server. However, certain options can be configured:DHCP 配置通常涉及设置DHCP 服务器以向客户端提供网络信息。在客户端,配置是最少的,因为客户端会自动从服务器请求设置。但是,可以配置某些选项:

  • On the DHCP Server (typically a router or a dedicated server):在 DHCP 服务器(通常是路由器或专用服务器)上
    • IP Address Range: Specify the range of IP addresses the server can assign.IP 地址范围:指定服务器可以分配的 IP 地址范围。
    • Lease Duration: Set the time period for which an IP address lease is valid.租用期限:设置 IP 地址租用的有效期限。
    • DNS Servers and Gateway: Provide the IP addresses for DNS servers and a default gateway.DNS 服务器和网关:提供 DNS 服务器的 IP 地址和默认网关。
  • On the DHCP Client (the device requesting an IP):在 DHCP 客户端(请求 IP 的设备)上
    • Usually, DHCP is enabled by default on client devices. The client’s settings can be found in network configuration files or a network manager interface.通常,客户端设备上默认启用 DHCP。客户端的设置可以在网络配置文件或网络管理器界面中找到。
    • On Linux systems, you typically configure DHCP in /etc/network/interfaces or by using NetworkManager. If using NetworkManager, you can set the connection type to DHCP in its graphical or command-line interface.在Linux系统上,您通常在/etc/network/interfaces中或使用NetworkManager配置 DHCP。如果使用 NetworkManager,您可以在其图形或命令行界面中将连接类型设置为 DHCP。

http://www.mrgr.cn/news/64233.html

相关文章:

  • atoi函数学习
  • Global Season of AI - 渐入佳境的生成式 AI
  • 架构师备考-软件工程相关补充
  • Linux之实战命令64:bridge应用实例(九十八)
  • 2-140 基于Solidworks和Matlab Simulink Simscape仿真的机器人手臂仿真
  • Qt 学习第十五天:连接mysql数据库进行增删查改操作
  • [每周一更]-(第121期):模拟面试|微服务架构面试思路解析
  • 使用 Faster Whisper 和 Gradio 实现实时语音转文字
  • 2024系统架构师---综合题考试真题答案
  • cangjie仓颉程序设计-程序结构(二)
  • 【含文档】基于ssm+jsp的超市订单后台理系统(含源码+数据库+lw)
  • Mac OS 配置Docker+Mysql
  • 2024 Rust现代实用教程 Trait特质
  • Docker:namespace隔离实战
  • 模板注入代码执行漏洞
  • 前端三件套(HTML + CSS + JS)
  • 为什么大家都在学数字孪生呢?
  • Ubuntu删除docker
  • DataFlow v202410 版本更新 一站式数据处理平台
  • WPF中的CommandParameter如何使用
  • 今日 AI 简报|零样本视频生成、移动端轻量语言模型、自动驾驶多模态模型等前沿 AI 技术集中亮相
  • JavaScript本地存储的方式有哪些
  • Linux安装部署MinIO
  • 常见 CSS 选择器用法
  • 七、Go语言快速入门之函数func
  • RHCE的练习(10)