http://sourceforge.net/projects/linux-igd
3、编译安装
由于linuxigd-0.92原来是基于1.0.4版的UPnP研发包研发的,所以需要适当改变以支持最新的1.2.1版UPnP研发包。
(1) 编译安装libupnp
tar xzvf libupnp-1.2.1.tar.gz
cd libupnp-1.2.1/upnp/
make DEBUG=1 WEB=0
make install
安装后UPnP研发包的头文档就安装在/usr/include/upnp目录下,库文档就安装在/usr/lib目录下。
(2) 编译安装linuxigd
tar xzvf linuxigd-0.92.tgz
cd linux-igd/
cp ../libupnp-1.2.1/upnp/sample/common/sample_util.c sample_util.cpp
cp ../libupnp-1.2.1/upnp/sample/common/sample_util.h sample_util.h
并修改sample_utils.cpp文档:
把第661行的
*controlURL =
替换为
*controlURL = (char *)
把第671行的
*eventURL =
替换为
*eventURL = (char *)
修改gateway.h文档:
把第29行的
#define INIT_PORT 2869
替换为
#define INIT_PORT 52869
修改gate.cpp文档:
在第34行插入3行
#define UpnpDocument_free ixmlDocument_free
#define UpnpParse_Buffer ixmlParseBuffer
typedef IXML_Document *Upnp_Document;
链接头文档目录:
ln -s ../libupnp-1.2.1/upnp/inc upnp
并修改gate.h文档:
把第27行的
#include
替换为
#include "upnp/upnp.h"
修改gateway.cpp文档:
把第36行的
#include
替换为
#include "upnp/upnp.h"
修改sample_util.h文档:
把第43行的
#include "upnptools.h"
替换为
#include "upnp/upnptools.h"
再修改Makefile文档:
把第3行的
LIBS= -lpthread /usr/lib/libupnp.so
替换为
LIBS= -lpthread -lupnp
以上都修改完后,执行make,make install
安装后执行文档在/usr/bin目录下,配置文档在/etc/linuxigd目录下。
4、配置运行
添加一条路由:
route add -net 239.0.0.0 netmask 255.0.0.0 eth1
这里eth1是连接内部网络的网卡。
在/usr/sbin目录下添加iptables的符号连接:
ln -s /sbin/iptables /usr/sbin/iptables
因为linux-igd使用/usr/sbin/iptables,而Redhat Linux 8.0的iptables在/sbin目录下。
启动linux-igd:
upnpd eth0 eth1
这里eth0是连接Internet的网卡。
upnpd的debug信息输出在/var/log/debug文档中,假如您的系统上没有这个文档,能够编辑/etc/syslog.conf文档,加入:
*.debug /var/log/debug
并重新启动syslogd就能够了。
5、功能测试
upnpd程式正常启动后,我们能够在/var/log/debug文档中看到如下信息:
Jun 15 17:49:43 svr upnpd: The Linux UPnP Internet Gateway Device Ver 0.92 by Dime (dime@gulfsales.com)
Jun 15 17:49:43 svr upnpd: Special Thanks for Intel's Open Source SDK and original author Genmei Mori's work.
Jun 15 17:49:43 svr upnpd: Intializing UPnP with desc_doc_url=http://192.168.0.1:52869/gatedesc.xml
Jun 15 17:49:43 svr upnpd: ipaddress=192.168.0.1 port=52869
Jun 15 17:49:43 svr upnpd: conf_dir_path=/etc/linuxigd/
Jun 15 17:49:43 svr upnpd: UPnP Initialization Completed
Jun 15 17:49:43 svr upnpd: Setting webserver root directory -- /etc/linuxigd/
Jun 15 17:49:43 svr upnpd: Registering the root device
Jun 15 17:49:43 svr upnpd: RootDevice Registered
Jun 15 17:49:43 svr upnpd: Initializing State Table
Jun 15 17:49:43 svr upnpd: State Table Initialized
Jun 15 17:49:45 svr upnpd: Advertisements Sent
上面的192.168.0.1是网关电脑的eth1的IP地址。
在内部网络中的电脑上启动MSN Messenger,和Internet上的其他Messenger用户测试语音聊天、文档传输都能够正常使用了。
在/var/log/debug文档中看到如下信息:
Jun 15 17:53:47 svr upnpd: AddPortMap: RemoteHost: (null) Prot: 17 ExtPort: 2032 Int: 192.168.0.19.12216
Jun 15 17:53:47 svr upnpd: AddPortMap: RemoteHost: (null) Prot: 6 ExtPort: 31989 Int: 192.168.0.19.13767
还能够使用iptables -t nat -L命令查看NAT配置情况,upnpd能够在PREROUTING中动态添加和删除表项。
注意:firewall还需要根据上面MSN Messenger的端口需要进行配置,在INPUT中开放相应的端口,并且FORWARD也需要ACCEPT。
五、参考资料
"NAT HOWTO",http://www.netfilter.org/documentation/
"Packet Filtering HOWTO",http://www.netfilter.org/documentation/
"Windows Messenger in Windows XP: Working with Firewalls and Network Address Translation Devices",
http://www.microsoft.com/windowsxp/pro/techinfo/deployment/natfw/default.asp
"UPnP NAT Traversal FAQ",http://www.microsoft.com/windowsxp/pro/techinfo/planning/networking/natfaq.asp
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




