[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Neue SkoleRouter LiveCD



Kurt Gramlich wrote:

> Alles Gute im neuen Jahr nochmals von mir!
> 
> Eine leicht verbesserte LiveCd steht zur Verfuegung:
> 
> rsync -vP skolelinux.de::download/SkoleRouter.070101.iso .
> 
> Diese startet beim Booten discover-modprobe und erkennt jetzt
> automatisch etwas mehr Hardware.

Der Router fährt bei mir ohne Probleme hoch, aber konfiguriert die
Netzwerkinterfaces in der falschen Reihenfolge: Das interne Interface
wird eth0, das externe eth1.

Man könnte den Router alle Interfaces nach dem Skolelinux-Netzwerk
bzw. tjener durchsuchen lassen.  Vielleicht ungefähr wie unten (als
Ergänzung für /etc/init.d/iptables).  Die Einträge für eth0 und eth1
könnten aus /etc/network/interfaces entfernt werden.

Viele Grüße,
Dennis

--snip--

#!/bin/sh

INT_IF=""
INT_IP="10.0.2.1"
INT_MASK="255.255.254.0"
TJENER="10.0.2.2"

INTERFACES=$(ifconfig -a | grep ^eth | cut -f1 -d' ')

# Step 1: Close all interfaces
for IF in $INTERFACES; do
	ifconfig $IF down
done

# Step 2: Find interface to tjener
for IF in $INTERFACES; do
	echo -n "Looking for tjener on $IF: "
	ifconfig $IF $INT_IP netmask $INT_MASK up
	if ping -c 1 $TJENER 1>/dev/null 2>&1 ; then
		echo "found"
		INT_IF="$IF"
		break
	fi
	echo "not found"
	ifconfig $IF 0.0.0.0
	ifconfig $IF down
done

[ -z "$INT_IF" ] && \
	echo "Warning: Cannot find interface to tjener" >&2

# Step 3: Find interface(s) to the world
for IF in $INTERFACES; do
	[ "$IF" != "$INT_IF" ] || continue
	echo "Starting dhclient for $IF..."
	dhclient -e $IF
done

echo 1 > /proc/sys/net/ipv4/ip_forward

# -------------- FIREWALL-REGELN -----------------------------

# delete existing rules
  iptables --flush
  iptables -t nat --flush
  iptables -t mangle --flush
      
# all allowed for localhost
  iptables -A INPUT -i lo -j ACCEPT
  iptables -A OUTPUT -o lo -j ACCEPT

# accept packages
  iptables --policy INPUT ACCEPT
  iptables --policy OUTPUT ACCEPT
  iptables --policy FORWARD ACCEPT

  iptables -t nat --policy PREROUTING ACCEPT
  iptables -t nat --policy OUTPUT ACCEPT
  iptables -t nat --policy POSTROUTING ACCEPT
      
  iptables -t mangle --policy PREROUTING ACCEPT
  iptables -t mangle --policy OUTPUT ACCEPT

# NAT for subnet

for IF in $INTERFACES; do
	[ "$IF" != "$INT_IF" ] || continue
	iptables -t nat -A POSTROUTING -o "$IF" -j MASQUERADE
done

# uncomment if you would check the rules
#  echo
#  echo             Table: filter 
#  iptables -n -L -v
#  echo
#  echo             Table: nat 
#  iptables -t nat -n -L -v
#  echo
#  echo             Table: mangle 
#  iptables -t mangle -n -L -v
#  echo
#  echo "#########################"


Reply to: