[Tutor] How can I do IP_MASQ by using Python?

Wenlong Liu gege@nst.pku.edu.cn
Tue, 30 Apr 2002 11:50:51 +0800


I want it can be run under linux/windows. so cannot related to iptables.
That means I need a lonely deamon to accept packages, rewite and redirect
them.

Regards

Ares
----- Original Message -----
From: "dman" <dman@dman.ddts.net>
To: <tutor@python.org>
Sent: Tuesday, April 30, 2002 4:53 AM
Subject: Re: [Tutor] How can I do IP_MASQ by using Python?

On Mon, Apr 29, 2002 at 09:03:14PM +0800, Wenlong Liu wrote:
| Re: [Tutor] How can I do IP_MASQ by using Python?MGCP is Media Gateway
Control Protocol. IETF RFC 2705
| http://www.ietf.org/rfc/rfc2705.txt?number=2705
|
| The Media Gateway Control Protocol (MGCP) is a signaling protocol
| for controlling Voice over IP (VoIP) Gateways from external call
| control elements across the Internet.  The protocol itself make
| extensive use of network addresses located inside the message body,
| since that it is impossible to use MGCP through basic network
| address translation/network address port translation without an
| Application Level Gateway (ALG).
|
| A MGCP message is identified by the ALG using UDP port 2427 or 2727
| as the destination port.  Actually the specified port number should
| be configurable. Most NAT implementations identify the type of
| traffic they will modify by using the port as an identifier, so this
| restriction seems practical.

Ok, I see now.  Yes you could do this sort of task with python.  You
would write a deamon to accept those packets on some other port,
parses and rewrites the body, then sends it out to the real
destination.  Use iptables to redirect incoming packets to be
intercepted by your daemon rather than being forwarded out the other
interface.

HTH,
-D

--