运维随笔录-记录分享IT技术经验的小站 - 2019年7月
type: channel
link: https://jdian.vip/2019/07/
description: 记录工作中遇到的一些技术问题，linux、windows、nginx、apache、mysql、mssql、web等一些技术问题，利人利己
items: windows2016 mysql连接慢，localhost被解析为ipv6的解决办法
items: VSftpd连接错误425 Security: Bad IP connecting解决方法

windows2016 mysql连接慢，localhost被解析为ipv6的解决办法
type: item
date: 2019-07-29T17:48:30+08:00
description: 今天遇到个奇怪的问题，mysql用localhost连接很慢，影响查询效率，服务器是windows2016，改用127.0.0.1就正常。网上查找资料，找到了一篇英文文章（原贴地址：http://superuser.com/questions/436574/ipv4-vs-ipv6-priority-in-windows-7/436944#436944）。大概意思是ipv6优先级高，localhost默认走ipv6地址。所以mysql用localhost时windows把localhost 解析为 ipv6 地址 ::1 而不是 127.0.0.1，发现连不上失败再走ipv4，这样就影响了数据库查询效率，目前的解决办法是修改用127.0.0.1连接mysql。另外还有一个解决方案，修改my.ini，添加bind-address = :: 监听ipv6，还可以按下面说的修改注册表。SOLUTION #1: ADD A PREFIX POLICY TO PREFER IPV4 ADDRESSES OVER IPV6Prefix policy table is similar a routing table, it determines which IP addresses are preferred when making a connection. Note that higher precedence in prefix policies is represented by a lager "precedence" value, exactly opposite to routing table "cost" value.Default Windows prefix policy table:C:\>netsh interface ipv6 show prefixpoliciesQuerying active state...Precedence Label Prefix---------- ----- --------------------------------50 0 ::1/12840 1 ::/030 2 2002::/1620 3 ::/9610 4 ::ffff:0:0/965 5 2001::/32Note that IPv6 addresses (::/0) are preferred over IPv4 addresses (::/96, ::ffff:0:0/96).We can create a policy that will make Hurricane Electric IPv6 tunnel less favourable than any IPv4 address:netsh interface ipv6 add prefixpolicy 2001:470::/32 3 62001:470::/32 is Hurricane Electric's prefix, 3 is a Precedence (very low) and 6 is a Label.I could have used a more generic prefix, but I wanted to make sure than if and when I get a direct IPv6 connectivity from an ISP, it will take precedence over IPv4.If you adapt this solution, you need to substitute an appropriate IPv6 prefix instead of my Hurricane Electric one.SOLUTION #2: TWEAK REGISTRY TO MAKE WINDOWS ALWAYS PREFER IPV4 OVER IPV6This solution is more generic, but more invasive and less standards-compliant. In the end, Windows will still modify the prefix policy table for you.Open RegEdit, navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tcpip6\ParametersCreate DisabledComponents DWORD registry value, set its value to 20 (Hexadecimal). See…

VSftpd连接错误425 Security: Bad IP connecting解决方法
type: item
date: 2019-07-29T17:46:16+08:00
description: 服务器安装的是VSftpd，连接的时候出现错误425 Security: Bad IP connecting原因：估计是网络通信方面存在问题触发了安全机制，比如ip变动等原因导致被安全机制拦截了。解决方法：vi /etc/vsftpd/vsftpd.conf添加：pasv_promiscuous=YESservice vsftpd restartpasv_promiscuous选项参数说明：此选项激活时，将关闭PASV模式的安全检查。该检查确保数据连接和控制连接是来自同一个IP地址。小心打开此选项。此选项唯一合理的用法是存在于由安全隧道方案构成的组织中。默认值为NO。其他方案：可以修改ftp设置，改成主动模式（port模式）进行尝试。再则本地防火墙杀毒软件可以临时关闭下，或者重启下本地路由。