iptables on bubba
Posted: 21 Mar 2007, 10:33
I was wondering why there is no iptables running on bubba ?
The package seems to be there.
Would something like this work to start iptables ?
#!/bin/bash
#for e1000 card to work the following are needed
echo "forcing eth0 to 100baseTx-FD full-duplex autoneg off"
/usr/sbin/ethtool -s eth0 duplex full speed 100 autoneg off
echo "forcing stupid settings on e1000 off"
/usr/sbin/ethtool -K eth0 rx off tx off sg off
#3com and other cards use this to configure them
#/bin/echo "forcing eth0 to 100baseTx-FD full-duplex"
#/sbin/mii-tool eth0 -F 100baseTx-FD
# full path of the programs we need - changed them to your needs
iptables=/sbin/iptables
modprobe=/sbin/modprobe
echo=/bin/echo
bubba='192.168.63.103'
# Load appropriate modules.
echo "load iptables module"
$modprobe ip_tables
# we load that modules as we want to do statefull firewalling
echo "load ip_conntrack module"
$modprobe ip_conntrack
# These lines are here in case rules are already in place and the script is ever rerun on the fly.
# We want to remove all rules and pre-exisiting user defined chains and zero the counters
# before we implement new rules.
$iptables -F
$iptables -X
$iptables -Z
echo "flush firewall rules"
iptables -F
iptables -F OUTPUT
iptables -F INPUT
iptables -F FORWARD
## LOOPBACK
# Allow unlimited traffic on the loopback interface.
# e.g. needed for KDE, Gnome
$iptables -A INPUT -i lo -j ACCEPT
$iptables -A OUTPUT -o lo -j ACCEPT
# Disable ICMP redirect acceptance. ICMP redirects can be used to alter your routing
# tables, possibly to a bad end.
$echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects
echo "no forwarding with only one network port"
$echo "0" > /proc/sys/net/ipv4/ip_forward
# don't want services that are not explictly allowed.
$iptables -P INPUT DROP
$iptables -P FORWARD DROP
$iptables -P OUTPUT DROP
# ---------------- INPUT ---------------------
## First rule is to let packetes through which belong to establisted or related connection
# and we let all traffic out as we trust ourself.
$iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
## ssh listens on port 22
$iptables -A INPUT -s 0/0 -p tcp --dport 22 -j ACCEPT
##mail server allowed
$iptables -A INPUT -p tcp -s 0/0 --dport 25 -j ACCEPT
##port 80 and 443
$iptables -A INPUT -p tcp -s 0/0 --dport 80-j ACCEPT
$iptables -A INPUT -p tcp -s 0/0 --dport 443 -j ACCEPT
##allow pings
$iptables -A INPUT -p icmp --icmp-type ping -j ACCEPT
The package seems to be there.
Would something like this work to start iptables ?
#!/bin/bash
#for e1000 card to work the following are needed
echo "forcing eth0 to 100baseTx-FD full-duplex autoneg off"
/usr/sbin/ethtool -s eth0 duplex full speed 100 autoneg off
echo "forcing stupid settings on e1000 off"
/usr/sbin/ethtool -K eth0 rx off tx off sg off
#3com and other cards use this to configure them
#/bin/echo "forcing eth0 to 100baseTx-FD full-duplex"
#/sbin/mii-tool eth0 -F 100baseTx-FD
# full path of the programs we need - changed them to your needs
iptables=/sbin/iptables
modprobe=/sbin/modprobe
echo=/bin/echo
bubba='192.168.63.103'
# Load appropriate modules.
echo "load iptables module"
$modprobe ip_tables
# we load that modules as we want to do statefull firewalling
echo "load ip_conntrack module"
$modprobe ip_conntrack
# These lines are here in case rules are already in place and the script is ever rerun on the fly.
# We want to remove all rules and pre-exisiting user defined chains and zero the counters
# before we implement new rules.
$iptables -F
$iptables -X
$iptables -Z
echo "flush firewall rules"
iptables -F
iptables -F OUTPUT
iptables -F INPUT
iptables -F FORWARD
## LOOPBACK
# Allow unlimited traffic on the loopback interface.
# e.g. needed for KDE, Gnome
$iptables -A INPUT -i lo -j ACCEPT
$iptables -A OUTPUT -o lo -j ACCEPT
# Disable ICMP redirect acceptance. ICMP redirects can be used to alter your routing
# tables, possibly to a bad end.
$echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects
echo "no forwarding with only one network port"
$echo "0" > /proc/sys/net/ipv4/ip_forward
# don't want services that are not explictly allowed.
$iptables -P INPUT DROP
$iptables -P FORWARD DROP
$iptables -P OUTPUT DROP
# ---------------- INPUT ---------------------
## First rule is to let packetes through which belong to establisted or related connection
# and we let all traffic out as we trust ourself.
$iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
## ssh listens on port 22
$iptables -A INPUT -s 0/0 -p tcp --dport 22 -j ACCEPT
##mail server allowed
$iptables -A INPUT -p tcp -s 0/0 --dport 25 -j ACCEPT
##port 80 and 443
$iptables -A INPUT -p tcp -s 0/0 --dport 80-j ACCEPT
$iptables -A INPUT -p tcp -s 0/0 --dport 443 -j ACCEPT
##allow pings
$iptables -A INPUT -p icmp --icmp-type ping -j ACCEPT