-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
256 lines (179 loc) · 7.68 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#
# README
#
# portfwd - Port Forwarding Daemon
#
# $Id: README,v 1.7 2002/07/30 13:09:12 evertonm Exp $
#
LICENSE
Portfwd - Port Forwarding Daemon
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
INTRODUCTION
Portfwd stands for port forwarding daemon. It's a small C++
utility which forwards incoming TCP connections and/or UDP
packets to remote hosts.
My apologies for my poor English. Corrections are welcome.
FEATURES
-- Forwarding of TCP segments.
-- Forwarding of UDP datagrams.
-- Forwarding of FTP in active and/or passive modes.
-- Transparent proxying available under Linux. Portfwd detects
such facility in "./configure" time by searching the
definition of MSG_PROXY in <sys/socket.h>.
-- DNS names for destination hosts can be resolved upon
start-up or on demand (see "on-the-fly" DNS option).
-- Portfwd can listen on specific local addresses.
-- Source addresses for outgoing connections can be explicitly
specified or automatically selected by the system.
-- Structured configuration language allows specification of
multiple simultaneous forwarding processes.
-- Portfwd spawns one forwarder process for each set of ports
which are subject to the same rules. Within a process, Portfwd
uses a select()-based event-loop to concurrently handle
several network events. There is no threading. There is no
further process creation after the startup of the configured
daemons.
-- The destination of a connection/datagram can be selected
based on its source address/port pair.
-- Portfwd allows simple round-robin load-balancing through
specification of multiple destinations.
-- Support for external destination selector program (aka
"director").
LIMITATIONS
-- Port ranges cannot be forwarded. Ports must be specified in
a one-by-one basis.
-- Specification of source address for outgoing UDP datagrams
require transparent proxy support available in the OS kernel.
-- The daemon must be restarted in order to update its
configuration.
-- A forwarding process blocks on some system calls, such as
connect().
BUILDING
This program has been compiled with gcc 2.95.2 and tested
under Debian Potato (Linux 2.2.19), but it may work on other
plataforms as well.
As of version 0.18, Portfwd has been ported for FreeBSD and
Solaris and there is support for autoconf/automake.
In order to compile:
./configure
make
A file named 'portfwd' should be produced.
INSTALL
To install 'portfwd' under /usr/local/sbin:
make install
Otherwise, just copy 'portfwd' to a suitable location.
CONFIG
The grammar for the configuration file is described in the
'conf.txt' file. Examples can be found in the 'cfg' directory.
For a quick experiment, use the following redirector, then
test with "telnet 127.0.0.1 10000". It should give you telnet
access to your local machine.
/*
* telnet.cfg
*
* Forward all connections on TCP port 10000 to 127.0.0.1:23
*/
tcp { 10000 { => 127.0.0.1:23 } }
/*
* eof: telnet.cfg
*/
Below you can see a more complete example using most features
of portfwd.
/*
* example.cfg
*/
user nobody
group nobody
tcp /* TCP connections */
{
/*
* Connections on port 12000 from subnet localhost/24 and
* ports in the range 0-5000 are forwarded to 127.0.0.1:23.
* Anything else goes to localhost:80.
*/
12000 {
localhost/24:+5000 => 127.0.0.1:23;
/* anything else */ => localhost:80
};
/*
* On port 11000, connections from address localhost, any
* port, are forwarded to 127.0.0.1:telnet.
*/
11000 { localhost => 127.0.0.1:telnet };
10000
ftp-active-mode-on 127.0.0.1
ftp-passive-mode-on 127.0.0.1
{ => localhost:ftp }
}
udp /* UDP packets */
{
/*
* All packets on port 10000 are forwarded to 127.0.0.1:11000.
*/
10000 { => 127.0.0.1:11000 }
}
/*
* eof: example.cfg
*/
RUNNING BASICS
1. START
Type:
portfwd -c <path_to_config_file>
2. STOP
Send a TERM signal to the Portfwd master process (the one with
lowest PID).
COMMAND LINE OPTIONS
Syntax Help
Option -h provides brief help on command line syntax.
Running in Foreground
The -g switch prevents Portfwd from going to
background.
Configuration File
Use -c <config_file_path> to specify the location of
your configuration file.
On-the-fly DNS
Portfwd usually solves all DNS hostnames upon
startup. Specify the -f option if you want the
destination hostnames be updated on demand. Be aware
this can affect TCP connection times and the whole UDP
forwarding performance.
Transparent Proxy
The -t switch enables transparent proxying; i.e. IP
address of outgoing data are "faked" to match those
from incoming data. If you plan to forward data to
hosts behind your firewall, you probably want this
option turned on, as it allows for your servers to see
original addresses of clients.
Of course, this feature requires transparent proxy
support compiled in your kernel, e.g.:
CONFIG_IP_TRANSPARENT_PROXY in Linux kernel.
Debugging
If the -d switch is given, portfwd will produce
verbose logging for debug purposes. Up to 3 switches
are meaningful.
Failure messages are sent to the system log under the
"daemon" facility.
Program Version
Portfwd version can be obtained by passing the -v
switch.
SUPPORT
If you have further questions, please consult the FAQ.
There is a discussion board in the Portfwd web site at Source
Forge:
http://portfwd.sf.net
This is probably the most useful resource for Portfwd users.
Anyway, one can contact me directly at:
Everton da Silva Marques
evertonsm at yahoo dot com dot br
-x-