1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-29 12:03:03 +00:00
freebsd/usr.sbin/ppp
Colin Percival d37df47d31 Join the 21st century: Cryptography is no longer an optional component
of releases.  The -DNOCRYPT build option still exists for anyone who
really wants to build non-cryptographic binaries, but the "crypto"
release distribution is now part of "base", and anyone installing from a
release will get cryptographic binaries.

Approved by:	re (scottl), markm
Discussed on:	freebsd-current, in late April 2004
2004-08-06 07:27:08 +00:00
..
acf.c Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
acf.h
arp.c Use the length of the interface name, not the length of its address when 2004-01-21 22:00:50 +00:00
arp.h
async.c Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
async.h Merge the NETGRAPH branch into HEAD. tty devices now use netgraph's line 2002-03-30 12:30:09 +00:00
atm.c Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
atm.h
auth.c Basic PAM authentication support. 2003-10-29 20:32:19 +00:00
auth.h Add support for MS-CHAP authentication via a RADIUS server. 2002-05-10 03:11:35 +00:00
bundle.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
bundle.h Do RADIUS accounting on IPV6CP. 2003-06-19 18:55:49 +00:00
cbcp.c Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
cbcp.h
ccp.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
ccp.h Understand the following Microsoft Vendor Specific RADIUS attributes: 2002-06-12 00:33:17 +00:00
chap_ms.c Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
chap_ms.h Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
chap.c Ignore case when comparing CHAP/CHAP81 responses 2003-11-10 21:56:02 +00:00
chap.h Compensate for dodgy Win98/WinME MSCHAPv2 responses later in the code 2002-06-17 01:12:38 +00:00
chat.c Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
chat.h
command.c Add configuration option "set pppoe [standard|3Com]" which allows 2004-07-29 05:59:43 +00:00
command.h Add a ``log'' command for logging specific information. 2001-11-03 21:45:32 +00:00
datalink.c Add a ``force-scripts'' option for using chat scripts with -direct and 2003-03-26 02:03:08 +00:00
datalink.h Merge the NETGRAPH branch into HEAD. tty devices now use netgraph's line 2002-03-30 12:30:09 +00:00
deflate.c Understand the following Microsoft Vendor Specific RADIUS attributes: 2002-06-12 00:33:17 +00:00
deflate.h
defs.c o Clean up some #includes 2002-05-14 12:55:39 +00:00
defs.h When it's necessary to kldload tun(4), don't forget to re-try to open 2002-04-15 00:14:40 +00:00
descriptor.h
ether.c Add configuration option "set pppoe [standard|3Com]" which allows 2004-07-29 05:59:43 +00:00
ether.h
exec.c o Clean up some #includes 2002-05-14 12:55:39 +00:00
exec.h
filter.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
filter.h
fsm.c Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:30:43 +00:00
fsm.h Increase the maximum FSM option length to 50 2002-05-22 21:17:13 +00:00
hdlc.c Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
hdlc.h Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
i4b.c o Clean up some #includes 2002-05-14 12:55:39 +00:00
i4b.h
id.c Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
id.h
iface.c Set link-local address of tun interface with prefixlen = 64 2003-04-04 11:09:08 +00:00
iface.h
ip.c Make getprotobynumber() calls in FilterCheck conditional on the log 2004-05-13 09:03:00 +00:00
ip.h
ipcp.c Support a ``set rad_alive N'' command to enable periodic RADIUS accounting 2004-07-17 01:07:53 +00:00
ipcp.h
iplist.c
iplist.h
ipv6cp.c Do RADIUS accounting on IPV6CP. 2003-06-19 18:55:49 +00:00
ipv6cp.h - made ppp compliant to RFC 2472 (based on a patch from another 2002-08-29 02:44:58 +00:00
layer.h
lcp.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
lcp.h Make the way FSM options are processed easier to read by using structures 2002-04-16 23:57:09 +00:00
link.c Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
link.h Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
log.c Support a ``set rad_alive N'' command to enable periodic RADIUS accounting 2004-07-17 01:07:53 +00:00
log.h Support a ``set rad_alive N'' command to enable periodic RADIUS accounting 2004-07-17 01:07:53 +00:00
lqr.c Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
lqr.h Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
main.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
main.h
Makefile Join the 21st century: Cryptography is no longer an optional component 2004-08-06 07:27:08 +00:00
mbuf.c Add a missing memcpy (*blush*!) 2004-04-17 00:29:17 +00:00
mbuf.h Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
mp.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
mp.h
mppe.c Don't trust the MPPE key lengths passed back from the RADIUS server. 2002-07-02 00:47:24 +00:00
mppe.h
nat_cmd.c Add Cisco Skinny Station protocol support to libalias, natd, and ppp. 2003-09-23 07:41:55 +00:00
nat_cmd.h Add Cisco Skinny Station protocol support to libalias, natd, and ppp. 2003-09-23 07:41:55 +00:00
ncp.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
ncp.h
ncpaddr.c Though manpage says that 0.0.0.0 can be used as HISADDR for gw 2003-06-21 10:14:52 +00:00
ncpaddr.h Don't adjust_linklocal() when pulling a sockaddr out of an ncpaddr or 2001-11-23 12:39:20 +00:00
netgraph.c Replace all uses of the old netgraph constants NG_*LEN by the new 2003-11-15 15:26:35 +00:00
netgraph.h Merge the NETGRAPH branch into HEAD. tty devices now use netgraph's line 2002-03-30 12:30:09 +00:00
pap.c Compensate for dodgy Win98/WinME MSCHAPv2 responses later in the code 2002-06-17 01:12:38 +00:00
pap.h
physical.c Add configuration option "set pppoe [standard|3Com]" which allows 2004-07-29 05:59:43 +00:00
physical.h Add configuration option "set pppoe [standard|3Com]" which allows 2004-07-29 05:59:43 +00:00
ppp.8.m4 Add configuration option "set pppoe [standard|3Com]" which allows 2004-07-29 05:59:43 +00:00
pred.c Understand the following Microsoft Vendor Specific RADIUS attributes: 2002-06-12 00:33:17 +00:00
pred.h
probe.c socket()s first argument should be a protocol family rather than an 2002-01-16 14:03:52 +00:00
probe.h
prompt.c If IPCP is disabled, susccess of IPV6CP negotiation is sufficient 2003-03-28 18:23:43 +00:00
prompt.h Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
proto.c
proto.h Consider PROTO_IPV6 as compressible by CCP. 2001-12-09 01:29:12 +00:00
radius.c Avoid casts as lvalues. 2004-07-28 07:20:04 +00:00
radius.h Support a ``set rad_alive N'' command to enable periodic RADIUS accounting 2004-07-17 01:07:53 +00:00
README.changes
README.devel Correct the FAQ url 2002-08-26 20:48:07 +00:00
README.nat Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
route.c We need filling scopeid to install routes for link-local 2003-03-25 16:49:08 +00:00
route.h
server.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
server.h
sig.c Add some missing #includes that weren't required due to namespace polution 2002-05-22 21:08:58 +00:00
sig.h
slcompress.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
slcompress.h
sync.c Re-implement LQM, this time according to the rfc. 2004-06-30 12:24:56 +00:00
sync.h
systems.c o Clean up some #includes 2002-05-14 12:55:39 +00:00
systems.h Add a ``log'' command for logging specific information. 2001-11-03 21:45:32 +00:00
tcp.c Remove unused calls to inet_addr() 2002-07-18 18:50:05 +00:00
tcp.h
tcpmss.c Reduce MAXMSS limit by 12 bytes to allow for rfc 1323. 2004-06-29 07:40:38 +00:00
tcpmss.h
throughput.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
throughput.h
timer.c Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_ 2002-08-27 20:11:58 +00:00
timer.h
tty.c Replace all uses of the old netgraph constants NG_*LEN by the new 2003-11-15 15:26:35 +00:00
tty.h
tun.c Remove whitespace at the end of lines. 2002-06-15 08:03:30 +00:00
tun.h
ua.h
udp.c Remove unused calls to inet_addr() 2002-07-18 18:50:05 +00:00
udp.h
vjcomp.c o Clean up some #includes 2002-05-14 12:55:39 +00:00
vjcomp.h

Copyright (c) 2001 Charles Mott <cm@linktel.net>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

$FreeBSD$

User PPP NAT (Packet Aliasing)



0. Contents
    1. Background
    2. Setup
    3. New commands in ppp
    4. Future Work
    5. Authors / Acknowledgements
    6. Revision History for Aliasing Code



1. Background

User mode ppp has embedded NAT (Network Address Translation) code.
Enabling this, either by the "-nat" command line option or the
"nat enable yes" command in a ppp.conf file, makes the ppp host
automatically NAT IP packets forwarded from a local network, making
them appear to come from the ppp host machine.  Incoming packets
from the outside world are then appropriately de-NAT'd.

The process of NAT'ing involves both the IP address and the TCP or UDP
port numbers. ICMP echo and timestamp packets are natted by their id
numbers.  ICMP error messages can be properly directed by examining the
fragment of the offending packet which is contained in the body of the
message.

This software was specifically meant to support users who have
unregistered, private address IP networks (e.g. 192.168.0.x or 10.0.0.x
addresses).  The ppp host can act as a gateway for these networks, and
computers on the local area net will have some degree of Internet access
without the need for a registered IP address.  Additionally, there will
be no need for an Internet service provider to maintain routing tables
for the local area network.

A disadvantage of NAT is that machines on the local network,
behind the ppp host, are not visible from the outside world.  They can
establish TCP connections and make UDP inquiries (such as domain name
service requests) but the connections seem to come from the ppp host
itself.  There is, in effect, a partial firewall.  Of course, if this is
what you want, the disadvantage becomes an advantage.

A second disadvantage is that "IP encoding" protocols, which send IP
address or port information within the data stream, are not supported
for the cases where exception code exists.  This implementation has
workarounds for FTP and IRC DCC, the most well known of the IP encoding
protocols.  This frees users from depending on using the ftp passive
mode and avoiding IRC DCC sends, as is sometimes the case with other
masquerading solutions.

The implementation supports all standard, non-encoding TCP and UDP protocols.
Examples of these protocols are http, gopher and telnet. The standard UDP
mode of Real-Audio is not presently supported, but the TCP mode does work
correctly.

The NAT code also handles many ICMP messages.  In particular,
ping and traceroute are supported.



2. Packet Aliasing Setup

It is recommended that users first verify correct ppp operation without
NAT enabled.  This will confirm that the ppp.conf file is
properly set up and that there are no ppp problems. Then start ppp with
the "-nat" option on the command line.  The user should verify that
the ppp host can correctly connect to the Internet in NAT
mode.  Finally, check that machines on the private network can access
the Internet.

The NAT software handles all packets, whether they come from
the host or another computer on the local area network.  Thus, a correctly
operating ppp host indicates that the software should work properly for
other computers on the private network.

If the ppp host can access the Internet, but other computers on the local
network cannot, check that IP forwarding is enabled on the ppp host. Also,
verify that the other computers use this machine as a gateway.  Of course,
you should also verify that machines within the local area network
communicate properly.  A common error is inconsistent subnet addresses
and masks.



3. New commands in ppp

In order to control NAT behaviour in a simple manner (no need for
recompilation), a new command has been added to ppp: nat.  This
is in addition to the -nat command line option.  System managers and
more experienced users may prefer to use the ppp command syntax
within the ppp.conf file.  The nat command also allows NAT
behaviour to be more precisely specified.

The decision to add a command instead of extending 'set' or 'option' was
to make obvious that these options only work when NAT is enabled.

The syntax for 'nat' is

    ppp>  nat option [yes|no]

where option is given by one of the following templates.


 - nat enable [yes|no]  (default no)

Enable NAT functionality.  If disabled, no other NAT
options will have any effect.  You should usually enable NAT
before routing any packets over the link; good points are in the
initial script or right before adding a route.  If you do not always
want NAT, consider using the -nat option to ppp instead of this
command.


 - nat deny_incoming [yes|no] (default yes)

Set to "yes" to disable all incoming connections.  This just drops
connections to, for example, ftp, telnet or web servers.  The NAT
mechanism prevents these connections. Technically, this option denies
all incoming TCP and UDP requests, making the NAT software a
fairly efficient one-way firewall.  The default is no, which will allow
all incoming connections to telnetd, ftpd, etc.


 - nat log [yes|no]

Controls logging of NAT link creation to "/var/log/alias.log" - this
is usually only useful if debugging a setup, to see if the bug is in
the PPP NATing.  The debugging information is fairly limited, listing
the number of NAT links open for different protocols.


 - nat same_ports [yes|no] (default yes)

When a connection is being established going through the NAT
routines, it will normally have its port number changed to allow the
NAT code to track it.  If same_ports is enabled, the NAT
software attempts to keep the connection's source port unchanged.
This will allow rsh, RPC and other specialised protocols to work
_most of the time_, at least on the host machine.  Please, do not
report this being unstable as a bug - it is a result of the way
NAT has to work. TCP/IP was intended to have one IP address
per machine.


 - nat use_sockets [yes|no] (default yes)

This is a fairly obscure option.  For the most part, the NAT
software does not have to allocate system sockets when it chooses a
NAT port number.  Under very specific circumstances, FTP data
connections (which don't know the remote port number, though it is
usually 20) and IRC DCC send (which doesn't know either the address or
the port from which the connection will come), there can potentially be
some interference with an open server socket having the same port number
on the ppp host machine.  This possibility for interference only exists
until the TCP connection has been acknowledged on both sides.  The safe
option is yes, though fewer system resources are consumed by specifying
no.


 - nat unregistered_only [yes|no] (default no)

NAT normally remaps all packets coming from the local area
network to the ppp host machine address.  Set this option to only map
addresses from the following standard ranges for private, unregistered
addresses:

                10.0.0.0     ->   10.255.255.255
                172.16.0.0   ->   172.31.255.255
                192.168.0.0  ->   192.168.255.255  */

In the instance that there is a subnet of public addresses and another
subnet of private addresses being routed by the ppp host, then only the
packets on the private subnet will be NAT'd.


- nat port <proto> <local addr>:<port>  <nat port>

This command allows incoming traffic to <nat port> on the host
machine to be redirected to a specific machine and port on the
local area network.  One example of this would be:

    nat port tcp 192.168.0.4:telnet  8066

All traffic to port 8066 of the ppp host would then be sent to
the telnet port (23) of machine 192.168.0.4.  Port numbers
can either be designated numerically or by symbolic names
listed in /etc/services.  Similarly, addresses can be either
in dotted quad notation or in /etc/hosts.


- nat addr <local addr> <public addr>

This command allows traffic for a public IP address to be
redirected to a machine on the local network.  This function
is known as "static NAT".  An address assignment of 0 refers
to the default address of the ppp host.  Normally static
NAT is useful if your ISP has allocated a small block of
IP addresses to the user, but it can even be used in the
case of a single, dynamically allocated IP address:

    nat addr 10.0.0.8 0

The above command would redirect all incoming traffic to
machine 10.0.0.8.

If several address NATs specify the same public address
as follows

    nat addr 192.168.0.2  public_addr
    nat addr 192.168.0.3  public_addr
    nat addr 192.168.0.4  public_addr

then incoming traffic will be directed to the last
translated local address (192.168.0.4), but outgoing
traffic to the first two addresses will still be NAT'd
to the specified public address.



4. Future Work

What is called NAT here has been variously called masquerading, packet
aliasing and transparent proxying by others.  It is an extremely useful
function to many users, but it is also necessarily imperfect.  The
occasional IP-encoding protocols always need workarounds (hacks).
Users who are interested in supporting new IP-encoding protocols
can follow the examples of alias_ftp.c and alias_irc.c.

ICMP error messages are currently handled only in the incoming direction.
A handler needs to be added to correctly NAT outgoing error messages.

IRC and FTP exception handling make reasonable, though not strictly correct
assumptions, about how IP encoded messages will appear in the control
stream.  Programmers may wish to consider how to make this process more
robust.

The NAT engine (alias.c, alias_db.c, alias_ftp.c, alias_irc.c
and alias_util.c) runs in user space, and is intended to be both portable
and reusable for interfaces other than ppp.  To access the basic engine
only requires four simple function calls (initialisation, communication of
host address, outgoing NAT and incoming de-NATing).



5. Authors / Acknowledgements

Charles Mott (cm@linktel.net)  <versions 1.0 - 1.8, 2.0, 2.1>
Eivind Eklund (perhaps@yes.no) <versions 1.8b - 1.9, new ppp commands>

Listed below, in chronological order, are individuals who have provided
valuable comments and/or debugging assistance.

    Gary Roberts
    Tom Torrance
    Reto Burkhalter
    Martin Renters
    Brian Somers
    Paul Traina
    Ari Suutari
    J. Fortes
    Andrzej Bialeki



6. Revision History for Aliasing Code

Version 1.0: August 11, 1996 (cjm)

Version 1.1:  August 20, 1996  (cjm)
    PPP host accepts incoming connections for ports 0 to 1023.

Version 1.2:  September 7, 1996 (cjm)
    Fragment handling error in alias_db.c corrected.

Version 1.3: September 15, 1996 (cjm)
    - Generalised mechanism for handling incoming connections
      (no more 0 to 1023 restriction).
    - Increased ICMP support (will handle traceroute now).
    - Improved TCP close connection logic.

Version 1.4: September 16, 1996
    Can't remember (this version only lasted a day -- cjm).

Version 1.5: September 17, 1996 (cjm)
    Corrected error in handling incoming UDP packets
    with zero checksum.

Version 1.6: September 18, 1996
    Simplified ICMP data storage.  Will now handle
    tracert from Win95 as well as FreeBSD traceroute.

Version 1.7: January 9, 1997 (cjm)
    - Reduced malloc() activity for ICMP echo and
      timestamp requests.
    - Added handling for out-of-order IP fragments.
    - Switched to differential checksum computation
      for IP headers (TCP, UDP and ICMP checksums
      were already differential).
    - Accepts FTP data connections from other than
      port 20.  This allows one ftp connections
      from two hosts which are both running packet
      aliasing.

Version 1.8: January 14, 1997 (cjm)
    - Fixed data type error in function StartPoint()
      in alias_db.c (this bug did not exist before v1.7)

Version 1.8b: January 16, 1997 (Eivind Eklund <perhaps@yes.no>)
    - Upgraded base PPP version to be the source code from
      FreeBSD 2.1.6, with additional security patches.  This
      version should still be possible to run on 2.1.5, though -
      I've run it with a 2.1.5 kernel without problems.
      (Update done with the permission of cjm)

Version 1.9: February 1, 1997 (Eivind Eklund <perhaps@yes.no>)
    - Added support for IRC DCC (ee)
    - Changed the aliasing routines to use ANSI style throughout -
      minor API changes for integration with other programs than PPP (ee)
    - Changed the build process, making all options switchable
      from the Makefile (ee)
    - Fixed minor security hole in alias_ftp.c for other applications
      of the aliasing software.  Hole could _not_ manifest in
      PPP+pktAlias, but could potentially manifest in other
      applications of the aliasing. (ee)
    - Connections initiated from packet aliasing host machine will
      not have their port number aliased unless it conflicts with
      an aliasing port already being used. (There is an option to
      disable this for debugging) (cjm)
    - Sockets will be allocated in cases where there might be
      port interference with the host machine.  This can be disabled
      in cases where the ppp host will be acting purely as a
      masquerading router and not generate any traffic of its own.
      (cjm)

Version 2.0: March, 1997 (cjm)
    - Incoming packets which are not recognised by the packet
      aliasing engine are now completely dropped in ip.c.
    - Aliasing links are cleared when a host interface address
      changes (due to re-dial and dynamic address allocation).
    - PacketAliasPermanentLink() API added.
    - Option for only aliasing private, unregistered IP addresses
      added.
    - Substantial rework to the aliasing lookup engine.

Version 2.1: May, 1997 (cjm)
    - Continuing rework to the aliasing lookup engine to support
      multiple incoming addresses and static NAT.
    - Now supports outgoing as well as incoming ICMP error messages/
    - PPP commands to support address and port redirection.