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
|
#
# $Id: lan-gateway.conf,v 1.3 2008/01/13 10:36:42 ktsaou Exp $
#
# Configuration file for a LAN router with one ethernet interface (eth0)
# for the LAN and a PPP interface for connecting to the Internet.
#
# The LAN works with private IP addresses.
#
# This script will also setup a transparent cache for all the PCs on the
# local LAN.
# ----------------------------------------------------------------------------
# CUSTOM SERVICES
# ----------------------------------------------------------------------------
# See the section "Adding Services" in the documentation
# Example service x, listening on port TCP/z
# > server_x_ports="tcp/z"
# > client_x_ports="default"
# ----------------------------------------------------------------------------
# NETWORK DEFINITIONS - Normally, only these are to be touched by you.
# ----------------------------------------------------------------------------
# You can define anything you like, assuming you are using it later.
# --- HOME ---
# The definition of our HOME LAN.
HOME_MYIP="10.0.0.1" # The IP on our HOME LAN
HOME_MYIF="eth0" # The HOME LAN interface
HOME_BCAST="10.0.255.255" # The HOME LAN broadcast
HOME_LAN="10.0.0.0/16" # The HOME LAN
HOME_SERVICES="all"
# Do we run a DHCP server on the HOME LAN?
HOME_DHCP=1 # Set to 0 to disable
# --- PUBLIC ---
# The definition of our PUBLIC interface.
PUBLIC_MYIP="" # Leave empty for dynamic IP
PUBLIC_MYIF="ppp+" # The public interface
PUBLIC_SERVICES="smtp http"
# Is the PPP interface a DIAL-ON-DEMAND?
DIAL_ON_DEMAND=1 # Set to 0 to disable
# --- TRUSTED ---
# Hosts in the internet I trust for accessing private services
# Empty these to disable.
TRUSTED_PCS="my-office-pc.example.com"
TRUSTED_SERVICES="ssh http"
# --- TRANSPARENT CACHE ---
# Run a transparent cache?
SQUID_PORT="3128" # Leave empty to disable SQUID
SQUID_USERS="squid" # Users to be excluded from the cache
SQUID_EXCLUDE="" # Web Server IPs to be excluded from the cache
# --- BLACKLIST ---
# A space-separated list of IPs to be blocked.
blacklist=""
# ----------------------------------------------------------------------------
# HELPERS
# ----------------------------------------------------------------------------
# Block all traffic from/to certain IPs
if [ ! -z "${blacklist}" ]
then
blacklist full "${blacklist}"
fi
# Setup a transparent squid, only if SQUID_PORT is set.
if [ ! -z "${SQUID_PORT}" ]
then
transparent_squid "${SQUID_PORT}" "${SQUID_USERS}" \
inface "${HOME_MYIF}" src "${HOME_LAN}" \
`test ! -z "${SQUID_EXCLUDE}" && echo "dst not '${SQUID_EXCLUDE}'"`
fi
# ----------------------------------------------------------------------------
# NETWORK ADDRESS TRANSLATION
# ----------------------------------------------------------------------------
# Change the source/destination of packets...
# Should we do SNAT or MASQUERADE?
# If there is a PUBLIC_MYIP defined, we should do SNAT, otherwise MASQ.
#
if [ ! -z "${PUBLIC_MYIP}" ]
then
snat to "${PUBLIC_MYIP}" \
outface "${PUBLIC_MYIF}" \
src "${HOME_LAN}" dst not "${UNROUTABLE_IPS}"
else
masquerade "${PUBLIC_MYIF}"
fi
# To have some public service hit an internal machine, do this:
# (the example redirects external port TCP/26 to internal IP 10.0.0.2 port 25)
#
# > dnat to 10.0.0.2:25 \
# > inface "${PUBLIC_MYIF}" \
# > src not "${HOME_LAN} ${UNROUTABLE_IPS}" \
# > proto tcp dport 26
#
# For each such statement, the router at the end has to support it.
# ----------------------------------------------------------------------------
# PROTECT SELF
# ----------------------------------------------------------------------------
# Protect the firewall host...
# --- HOME ---
# Protect us from the HOME LAN
interface "${HOME_MYIF}" home src "${HOME_LAN}" dst "${HOME_MYIP} ${HOME_BCAST}"
policy reject
server "${HOME_SERVICES}" accept
client all accept
# DHCP needs 0.0.0.0/255.255.255.255 access.
if [ ${HOME_DHCP} -eq 1 ]
then
interface "${HOME_MYIF}" dhcp
server dhcp accept
fi
# --- PUBLIC ---
# Protect us from the PUBLIC
interface "${PUBLIC_MYIF}" internet \
src not "${UNROUTABLE_IPS}" \
`test ! -z "${PUBLIC_MYIP}" && echo "dst ${PUBLIC_MYIP}"`
protection strong
policy drop
# Are there any trusted PCs/services?
if [ ! -z "${TRUSTED_PCS}" -a ! -z "${TRUSTED_SERVICES}" ]
then
server "${TRUSTED_SERVICES}" accept src "${TRUSTED_PCS}"
fi
server "${PUBLIC_SERVICES}" accept
client all accept
# DIAL-ON-DEMAND needs this in case there is a PUBLIC_MYIP defined.
if [ ${DIAL_ON_DEMAND} -eq 1 ]
then
interface "${PUBLIC_MYIF}" dialup
client all accept
fi
# ----------------------------------------------------------------------------
# PROTECT ROUTING
# ----------------------------------------------------------------------------
# Protect the LAN...
# Route traffic for the clients on the LAN
router internet2lan inface "${PUBLIC_MYIF}" outface "${HOME_MYIF}" \
src not "${UNROUTABLE_IPS}" dst "${HOME_LAN}"
# route all client traffic
client all accept
# For the dnat example above, this is needed:
# > server smtp accept dst 10.0.0.2
|