一起去看海

2011/08/06

利用iptables进行端口映射

Filed under: Linux笔记, 经验分享 — Tags: — admin @ 16:46

由于公司不同网段的区分,导致互访很不方便。别的网段的用户要访问我们的服务器,通过端口映射是比较方便的方式。
PC A: eth0  10.10.1.11,  eth1 192.168.0.11
PC B:    eth1  192.168.0.20

要使访问A的10.10.1.11:8000端口能访问到B的8000端口,通过iptables就能简单实现。命令如下:

[shell]
iptables -t nat -A PREROUTING -d 10.10.1.11 -p tcp –dport 8000 -j DNAT –to-destination 192.168.0.20:8000
iptables -t nat -A POSTROUTING -d 192.168.0.20 -p tcp –dport 8000 -j SNAT –to 192.168.0.11
iptables -A FORWARD -o eth1 -d 192.168.0.20 -p tcp –dport 8000 -j ACCEPT
iptables -A FORWARD -i eth1 -s 192.168.0.20 -p tcp –sport 8000 -j ACCEPT
[/shell]

其中前面两条是必须的,如果你的iptables还有其他规则,或者默认策略为drop,最好加上后面两条。
还有一个不得不改的地方是 /etc/sysctl.conf,将net.ipv4.ip_forward的值改为1。
为了使设置生效,可以使用 sysctl -p 命令刷新。有些教程说要重启系统才可以,其实就是没用这个命令。还有些教程说要修改 /proc/sys/net/ipv4/ip_forward,其实和sysctl -p的作用是一样的。

————————————华丽的分割线——————————————

除了用iptables外,还可以用软件rinetd。

rinetd的下载地址: http://www.boutell.com/rinetd/http/rinetd.tar.gz

下载之后解压:tar -zxvf rinetd.tar.gz,之后就是简单的make, make install。安装时会提示没有/usr/man/ 文件夹,手动创建一个再试即可。在centos5下编译会提示警告,可以无视。

编辑/etc/rinetd.conf,按如下格式添加
绑定地址 绑定端口 目的地址 目的端口
例如
10.10.1.11 8000 192.168.0.20 8000
如果要绑定主机上的所有IP,可以用0.0.0.0代替。
完成后启动rinetd。
rinetd -c /etc/rinetd.conf
关闭rinetd
pkill rinetd

2010/11/14

WORD转CHM工具

Filed under: 经验分享 — Tags: — admin @ 21:30

发现一个word转CHM文件的工具Macrobject Word-2-CHM,相当好用。免费软件,但是免费版有水印,收费的才能去掉。找了很久最新版的注册码都没有办法破解,于是安装了个旧版本的,功能差不多,生成的CHM比较不错,特推荐之~

下载地址: Macrobject Word-2-CHM 3.0.0.135.rar

2010/11/13

IETester有官网了

Filed under: Web开发 — Tags: — admin @ 10:24

最近做的网站快上线了,要做浏览器的兼容性测试,于是想起了很久以前用的IETester。网上找了一下,IETester居然开了个官网,而且IETester的更新也比较勤快了。记得以前用的时候总是动不动就崩溃,很纠结~~现在最新的0.46版已经比较稳定了,用着感觉很不错。

做前台开发的童鞋可以去看看:http://www.ietester.org/

2010/03/28

IE也能用Firebug

Filed under: Web开发 — Tags: — admin @ 16:42

Firebug 是火狐的一个插件,如果你想在IE、Opera和Safari上也使用Firebug调试网页,解决办法就是Firebug Lite。Firebug Lite是一个用JavaScript写的工具,直接在你的页面中导入Firebug Lite就可以使用Firebug插件的功能,而且支持IE、Opera和Safari。

原文:

Firebug is an extension for Firefox, but what happens when you need to test your pages in Internet Explorer, Opera, and Safari?

The solution is Firebug Lite, a JavaScript file you can insert into your pages to simulate some Firebug features in browsers that are not named “Firefox”.

Firebug Lite creates the variable “firebug” and doesn’t affect or interfere with HTML elements that aren’t created by itself.

Screenshots:

Latest Version: 1.2.1 (2008-09 CHANGELOG)

Installing Firebug Lite 1.2

Insert this line of code into any page that you want to contain Firebug lite:

    <script type='text/javascript'
        src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>

Firebug Lite as bookmarklet

Drag the following link to your bookmark toolbar and use Firebug Lite on any page:

Firebug Lite

Configuring Firebug Lite

Height of the firebug lite form is resizeable in latest version;

  <script type="text/javascript">
  firebug.env.height = 500;
  </script>

Also, developers can use their own css file;

  <script type="text/javascript">

  firebug.env.css = "/myown/firebug.css"
  </script>

Using Firebug Lite Offline

Download the source

Import firebug-lite-compressed.js or firebug-lite.js into your site’s directory. Find “firebug-lite.css” URL on the javascript file which you imported and replace this with offline address of firebug-lite.css file.

    <script language="javascript" type="text/javascript"
        src="/path/to/firebug/firebug-lite.js"></script>

Commands

Now FBLite supports all basic commands of Firebug.

firebug.watchXHR: Use this function to watch the status of XmlHttpRequest objects.

    var req = new XmlHttpRequest;
    firebug.watchXHR(req);

firebug.inspect: Now elements can be inspected in javascript code:

 firebug.inspect(document.body.firstChild);

On some browsers, the console object is already declared. If you observe errors in Safari, for instance, use the console commands in this fashion:

    firebug.d.console.cmd.log("test");
    firebug.d.console.cmd.dir([ "test" ]);

Notes

On some browsers, the console object is already declared. If you observe errors in Safari, for instance, use the console commands in this fashion:

    firebug.d.console.cmd.log("test");
    firebug.d.console.cmd.dir([ "test" ]);

Firebug Lite creates the variables “firebug” and doesn’t affect or interfere HTML elements that aren’t create by itself.

网站:http://getfirebug.com/firebuglite

Powered by WordPress