Linux 网络优化配置: sysctl 参数详解与 VPN 连接故障排查

sysctl 参数设置

以下 sysctl 参数通常用于优化 Linux 系统的网络性能,但仅凭这些设置可能不足以解决 VPN 连接到远程桌面的问题。

#!!! Do not change these settings unless you know what you are doing !!!
net.ipv4.ip_forward = 1
#net.ipv4.conf.all.forwarding = 1
#net.ipv4.conf.default.forwarding = 1
################################
#net.ipv6.conf.all.forwarding = 1
#net.ipv6.conf.default.forwarding = 1
#net.ipv6.conf.lo.forwarding = 1
################################
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
################################
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.default.accept_ra = 2
################################
net.core.netdev_max_backlog = 1048576
net.core.netdev_budget = 50000
#fs.file-max = 51200
net.core.rmem_max = 524288000
net.core.wmem_max = 524288000
net.core.rmem_default = 10000000
net.core.wmem_default = 11059200
net.core.somaxconn = 1048576
################################
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_keepalive_intvl = 12
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_synack_retries = 3
net.ipv4.tcp_syn_retries = 3
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_rfc1337 = 1
#net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 12
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_rmem = 30000000 30000000 67108864
net.ipv4.tcp_wmem = 30000000 30000000 67108864
net.ipv4.tcp_mem = 94500000 91500000 92700000
net.ipv4.udp_rmem_min = 16384
net.ipv4.udp_wmem_min = 16384
net.ipv4.tcp_mtu_probing = 0
##############################
net.ipv4.conf.all.arp_ignore = 2
net.ipv4.conf.default.arp_ignore = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_announce = 2
##############################
net.ipv4.tcp_autocorking = 0
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_max_syn_backlog = 1048576
net.core.default_qdisc = fq_codel
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_notsent_lowat = 81920
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_ecn = 2
net.ipv4.tcp_ecn_fallback = 1
net.ipv4.tcp_frto = 0
##############################
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
vm.swappiness = 0
net.ipv4.ip_unprivileged_port_start = 0
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_sack = 1
fs.file-max = 40000500
fs.nr_open = 40000500
###########new
net.netfilter.nf_conntrack_max = 1048576
net.nf_conntrack_max = 1048576
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 30
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 30
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 15
net.netfilter.nf_conntrack_tcp_timeout_established = 60
net.ipv4.tcp_max_orphans = 131072
net.ipv4.tcp_retries2 = 5
###########
net.core.optmem_max = 10000000
net.ipv4.tcp_fack = 1
net.ipv4.tcp_retrans_collapse = 1

VPN 网络无法连接到远程桌面内容:

如果您的 VPN 连接无法连接到远程桌面,可以尝试以下故障排查步骤:

  1. 检查 VPN 配置: 确保客户端和服务器端的 VPN 配置正确,包括 IP 地址、身份验证方法和加密设置。

  2. 检查防火墙设置: 验证客户端和服务器端防火墙是否允许 VPN 连接所需的端口和协议。常见的 VPN 连接端口有:

    • UDP 500 和 4500(IKEv2)
    • UDP 1194(OpenVPN)
    • TCP 1723(PPTP)
  3. 检查 VPN 服务器日志: 查看 VPN 服务器日志中是否有错误消息或警告,这些信息可以帮助您找到连接问题的根源。

  4. 从不同的网络测试 VPN 连接: 尝试从不同的网络或使用不同的互联网连接连接到 VPN,以确定问题是否与您的当前网络有关。

  5. 更新 VPN 客户端软件: 确保您使用的是最新版本的 VPN 客户端软件。过时的软件可能会导致兼容性问题或安全漏洞。

  6. 禁用杀毒软件/防火墙: 暂时禁用您的计算机上的任何杀毒软件或防火墙,然后再次测试 VPN 连接。有时,这些安全软件可能会干扰 VPN 连接。

  7. 联系 VPN 服务提供商: 如果您使用的是第三方提供的 VPN 服务,请联系他们的支持团队寻求帮助。他们可能提供特定的故障排除步骤,或能够识别其服务中存在的已知问题。

这些是一些通用的故障排除步骤,具体的解决方案可能因 VPN 软件和底层网络基础设施而异。建议您查阅您所用 VPN 解决方案的文档或支持资源,获取更详细的故障排除步骤。

希望这些信息对您有所帮助。如果您有任何其他问题,请随时提出。


原文地址: https://www.cveoy.top/t/topic/qDIj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录