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

[ Re: Linux als Router für Windows]



hi

benutze das angehängte firewall script.
kopiere es nach /etc/init.d/
achte darauf, dass es ausführbar ist (chmod +x /etc/init.d/firewall).
jetzt kannst du es mit "/etc/init.d/firewall start" starten.
das ganze funktioniert nur, wenn deine eth1 die ip mit dhcp
bezieht. ich weiss nicht wie dsl arbeitet, da ich mit cable fahre...
damit es nach dem booten schon gestartet wird solltest du noch
symb. links in den runlevel-directories anbringen.

gruss
eric

ps: im internet gibts 1000 tutorials darüber!!


Christoph Strins wrote:
Hallo,

ich möchte von meinem Windows-Rechner (192.168.1.99) über meinen Linux-Rechner (192.168.1.100) ins Internet gehen. Der Linux-Rechner hat zwei Netzwerkkarten: eth0 fürs interne Netz und eth1 für DSL. Wie muss ich da vorgehen?

Christoph



#! /bin/sh
#
# firewall      firewall init-script
#               This file should be placed in /etc/init.d/
#
#               Written Eric Marchionni
#
# Version       v1.0   21-Apr-2003
#

NAME="firewall"

fw_up () {
# enabling ip-forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
# support for dynamic IP-addresses
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
# activate SYN cookie protection
echo "1" > /proc/sys/net/ipv4/tcp_syncookies

#load required modules
modprobe ip_tables
modprobe ip_conntrack
modprobe iptable_filter
modprobe iptable_mangle
modprobe iptable_nat
modprobe ipt_limit
modprobe ipt_state

# non-required modules
#modprobe ipt_log
#modprobe ipt_owner
#modprobe ipt_reject
#modprobe ipt_masquerade
#modprobe ip_conntrack_ftp
#modprobe ip_conntrack_irc
#modprobe ip_nat_ftp
#modprobe ip_nat_irc

###################
#  CONFIGURATION  #
###################


# interface definitions of ROUTER

WAN_IFACE=eth1
WAN_ADDR=`ifconfig $WAN_IFACE | grep inet | sed -e "s/.*inet addr://" -e "s/ Bcast.*//"`
LAN_IFACE=eth0
LAN_ADDR=192.168.1.0/24


##############
#  CLEANING  #
##############

# flush all tables
iptables -F			# flush filter-chains
iptables -t nat -F		# flush NAT-chains
iptables -X			# delete all non-buildin chains

# set default policies: drop everything
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# in local-loopback-device we trust
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT


##############
#  INCOMING  #
##############

# WAN -> ROUTER
iptables -A INPUT -i $WAN_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT

# LAN -> ROUTER
iptables -A INPUT -i $LAN_IFACE -j ACCEPT


##############
#  OUTGOING  #
##############

# ROUTER -> WAN, LAN
iptables -A OUTPUT -o $WAN_IFACE -j ACCEPT
iptables -A OUTPUT -o $LAN_IFACE -j ACCEPT


################
#  FORWARDING  #
################

# WAN -> LAN
iptables -A FORWARD -i $WAN_IFACE -o $LAN_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT

# LAN -> WAN
iptables -A FORWARD -i $LAN_IFACE -o $WAN_IFACE -j ACCEPT


##################
#  MASQUERADING  #
##################

# LAN -> WAN
iptables -t nat -A POSTROUTING -o $WAN_IFACE -j MASQUERADE
}


fw_down() {
##############
#  CLEANING  #
##############

# flush all tables
iptables -F			# flush filter-chains
iptables -t nat -F		# flush NAT-chains
iptables -X			# delete all non-buildin chains

# set default policies: drop everything
iptables -P INPUT ACCEPT 
iptables -P FORWARD ACCEPT 
iptables -P OUTPUT ACCEPT 
}


case "$1" in
  start)
        echo -n "Starting $NAME: "
	fw_up
        echo "...done!"
        ;;
  stop)
        echo -n "Stopping $NAME: "
	fw_down
        echo "...done!"
        ;;
  restart|force-reload)
        echo -n "Stopping $NAME: "
        fw_down
	echo "...done!"
        sleep 1
	echo -n "Starting $NAME: "
        fw_up
        echo "...done!"
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0



Reply to: