Efficiency
Use Wireshark to capture loopback traffic without a loopback adapter
0If you’ve ever used Wireshark for debugging applications you may have noticed that it only seems to pick up traffic that is actually transmitted over the wire and ignores all traffic sent to your local ip address or localhost. If you want to watch this traffic without having to install a special loopback adapter you can use the following trick.
How to force local traffic to your default gateway
1) Open a command prompt (Run as Administrator for Vista/7)
2) Type ipconfig/all (note your local ip address(es) and default gateway)
3) Type “route add <your ip address> mask 255.255.255.255 <default gateway IP address> metric 1″
This instructs windows to send any requests for your local ip address to your default gateway, which will in turn forward the request back to your machine. Be aware that this route will disappear once you restart your machine unless you include the -p switch after the route command. You may also notice an echo effect if you’re using Wireshark because you see each request and response twice. You can remove this problem by applying the following filter at the top.
ip.src==<default gateway> or ip.dst==<default gateway>
Consider the default gateway as a client trying to reach your machine and all traffic sent to the default gateway as your machine’s response.
To remove the route, type “route delete <the ip address you entered>”.
If you have an application running locally that uses localhost, you can map localhost to the IP address you added a route for. Just don’t forget you mapped localhost to a different IP than 127.0.0.1!
How to map localhost
1) Open notepad (Run as Administrator in Vista/7)
2) Navigate to C:\Windows\System32\drivers\etc\ and open the hosts file (there’s no extension).
3) Add this entry “<the IP address you added a route for> localhost”. Note that the space between the ip address and localhost is a tab.
Now, when your machine tries to send something to localhost, it will resolve to the IP address you added a route for and send its traffic to your default gateway.
(Important!) Remember to unblock the port used for incoming traffic on your machine. Also, if you find that an application you’re using doesn’t seem to send out traffic the way you expect, try flushing the dns cache with ipconfig/flushdns.
用工具提高效率 解决 PhpMyAdmin 乱码
0最近做的项目有点特殊,多人共用开发服务器,无法搭建个人独享的开发环境。
连数据库,不能使用客户端的 GUI 工具,本来我已经离不开 SQLyog 了,现在逼我用命令行,我怎么受得了?
欣慰的是,尽管 MySQL server 虽然不在开发服务器上,也没有 root 权限给我的 IP 做授权,但开发服务器的 IP 是在授权列表内的。
我又想起了 PhpMyAdmin 这个好久不用的工具。
在 Dev server 上装好,配好用户名和密码,然后即可访问 MySQL,不过又遇到新问题!
MySQL server、Database、Table 和 Column 的字符集都是 latin1,而写入数据库的字符是 GBK。虽然设计不够合理,但也算勉强能用,用 SecureCRT 的命令行连接 MySQL,是可以看到正确的中文字符的,因为 SecureCRT 设置的是默认的字符集。
但 PhpMyAdmin 却总是乱码!
查了下 Variables 标签,有 2 个关于字符集的高亮提示,意思是全局设置是 latin1,但 character set client 是 utf8。
任凭我怎么改 MySQL connection collation 的设置,都无效。
tail 了一下 MySQL query log,看到 PhpMyAdmin 总是发送
SET CHARACTER SET ‘utf8′
SET collation_connection = ‘utf8_general_ci’
这 2 条语句!
我又 grep 一下,看到有个文件中的代码,让这 2 条语句被强制执行!
用 解决 PhpMyAdmin 字符乱码问题 所述的方法修改,即刻解决问题!
这下又能高效的访问 MySQL 啦,我相信打字再快的人,输入一条 Select 语句也没有我点击一下鼠标快!
