Robert,
I started with the rules from the old IP-masq mini-HOWTO, and converted
them to ipchains. This is really the minimal set of rules you should use
for safety and responsibility (avoid spewing unroutable packets into the
real world...). They allow access to any port from any source, provided
the packets survive some simple sanity checking, and therefore they
don't
provide any security at all. This script forms a good basis upon which
to build something more secure, which I recommend you do.
HTH,
-- Joe
Robert Heaven wrote:
>
> MediaNone is scheduled to come out this week to install my cable modem
> service. I have an old Compaq P133 with RH6.1 on it and plan to install 2
> NIC's and use as a firewall. I've read "Linux Firewalls" by Robert L.
> Ziegler and he seems a bit paranoid and his examples are much more complex
> than my simple one LAN gateway/firewall. I've also read the IPCHAINS-HOWTO
> by Paul Russell, who's much less paranoid but, his examples are also too
> complex.
> I would greatly appreciate any good ipchains scripts that anyone would
> consider sending me.
>
> Thanks,
> Robert
>
> --
> To unsubscribe: mail ">majordomo@ale.org with "unsubscribe ale" in message body.
-- Joe Knapka
* What happens when a mysterious force meets an inscrutable object?
# Get our IP address as supplied by the DHCP server. With
# asymmetric cable, use the address of ppp0 here instead.
source /etc/dhcpc/dhcpcd-eth1.info
CABLEADDR=${IPADDR}
# Other useful constants.
CABLEIFC=eth1
LOCALIFC=eth0
ANYWHERE="0.0.0.0/0"
LOOPBACK=lo
# Note: you will want to change these, probably.
LOCALADDR="192.168.81.1"
LOCALNET="192.168.81.0/24"
# Standard way of rejecting a packet is to log it and then drop it on the floor.
STD_REJECT="-l -j DENY"
# Flush and set all policies to DENY.
echo ipchains -F
ipchains -F
echo ipchains -P input DENY
ipchains -P input DENY
echo ipchains -P output DENY
ipchains -P output DENY
echo ipchains -P forward DENY
ipchains -P forward DENY
# local interface, local machines, going anywhere is valid
echo ipchains -A input -i ${LOCALIFC} -s ${LOCALNET} -d ${ANYWHERE} -j ACCEPT
ipchains -A input -i ${LOCALIFC} -s ${LOCALNET} -d ${ANYWHERE} -j ACCEPT
# remote interface, claiming to be local machines, IP spoofing, get lost
echo ipchains -A input -i ${CABLEIFC} -s ${LOCALNET} -d ${ANYWHERE} ${STD_REJECT}
ipchains -A input -i ${CABLEIFC} -s ${LOCALNET} -d ${ANYWHERE} ${STD_REJECT}
# remote interface, any source, going to permanent CABLEIFC address is valid
# (Note that with asymmetric cable modem service, incoming packets
# destined for the permanent address will appear on CABLEIFC, not ppp0.)
echo ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} -d ${CABLEADDR} -j ACCEPT
ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} -d ${CABLEADDR} -j ACCEPT
# loopback interface is valid.
echo ipchains -A input -i ${LOOPBACK} -s ${ANYWHERE} -d ${ANYWHERE} -j ACCEPT
ipchains -I input -i ${LOOPBACK} -j ACCEPT
# catch all rule, all other incoming is denied and logged. pity there is no
# log option on the policy but this does the job instead.
echo ipchains -A input -s ${ANYWHERE} -d ${ANYWHERE} ${STD_REJECT}
ipchains -A input -s ${ANYWHERE} -d ${ANYWHERE} ${STD_REJECT}
# Outgoing:
# local interface, any source going to local net is valid
echo ipchains -A output -i ${LOCALIFC} -s ${ANYWHERE} -d ${LOCALNET} -j ACCEPT
ipchains -A output -i ${LOCALIFC} -s ${ANYWHERE} -d ${LOCALNET} -j ACCEPT
# outgoing to local net on remote interface, stuffed routing, ${STD_REJECT}
echo ipchains -A output -i ${CABLEIFC} -s ${ANYWHERE} -d ${LOCALNET} ${STD_REJECT}
ipchains -A output -i ${CABLEIFC} -s ${ANYWHERE} -d ${LOCALNET} ${STD_REJECT}
# outgoing from local net on remote interface, stuffed masquerading, ${STD_REJECT}
echo ipchains -A output -i ${CABLEIFC} -s ${LOCALNET} -d ${ANYWHERE} ${STD_REJECT}
ipchains -A output -i ${CABLEIFC} -s ${LOCALNET} -d ${ANYWHERE} ${STD_REJECT}
# outgoing to local net on remote interface, stuffed masquerading, ${STD_REJECT}
echo ipchains -A output -i ${CABLEIFC} -s ${ANYWHERE} -d ${LOCALNET} ${STD_REJECT}
ipchains -A output -i ${CABLEIFC} -s ${ANYWHERE} -d ${LOCALNET} ${STD_REJECT}
# anything else outgoing on remote interface is valid
echo ipchains -A output -i ${CABLEIFC} -s ${CABLEADDR} -d ${ANYWHERE} -j ACCEPT
ipchains -A output -i ${CABLEIFC} -s ${CABLEADDR} -d ${ANYWHERE} -j ACCEPT
# loopback interface is valid.
echo ipchains -A output -i ${LOOPBACK} -s ${ANYWHERE} -d ${ANYWHERE} -j ACCEPT
ipchains -I output -i ${LOOPBACK} -j ACCEPT
# catch all rule, all other outgoing is denied and logged. pity there is no
# log option on the policy but this does the job instead.
echo ipchains -A output -s ${ANYWHERE} -d ${ANYWHERE} ${STD_REJECT}
ipchains -A output -s ${ANYWHERE} -d ${ANYWHERE} ${STD_REJECT}
# Forwarding:
# Masquerade local machines as if they were this one.
echo ipchains -A forward -i ${CABLEIFC} -s ${LOCALNET} -d ${ANYWHERE} -j MASQ
ipchains -A forward -i ${CABLEIFC} -s ${LOCALNET} -d ${ANYWHERE} -j MASQ
echo 1 > /proc/sys/net/ipv4/ip_forward
# loopback interface is valid.
echo ipchains -A forward -i ${LOOPBACK} -j ACCEPT
ipchains -I forward -i ${LOOPBACK} -j ACCEPT
# catch all rule, all other outgoing is denied and logged. pity there is no
# log option on the policy but this does the job instead.
echo ipchains -A forward -s ${ANYWHERE} -d ${ANYWHERE} ${STD_REJECT}
ipchains -A forward -s ${ANYWHERE} -d ${ANYWHERE} ${STD_REJECT}
####################################################################
# Samba protection. These rules prevent your Samba shares from being
# browseable by, well, anyone...
#echo ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 53 -p udp -d ${CABLEADDR} -j ACCEPT
# ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 53 -p udp -d ${CABLEADDR} -j ACCEPT
#echo ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 110 -p udp -d ${CABLEADDR} -j ACCEPT
# ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 110 -p udp -d ${CABLEADDR} -j ACCEPT
#echo ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 113 -p udp -d ${CABLEADDR} -j ACCEPT
# ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 113 -p udp -d ${CABLEADDR} -j ACCEPT
#echo ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 123 -p udp -d ${CABLEADDR} -j ACCEPT
# ipchains -A input -i ${CABLEIFC} -s ${ANYWHERE} 123 -p udp -d ${CABLEADDR} -j ACCEPT
--
To unsubscribe: mail ">majordomo@ale.org with "unsubscribe ale" in message body.