Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
adsl internet freigabe
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
Xe
Apprentice
Apprentice


Joined: 02 Sep 2004
Posts: 254
Location: Karlsruhe, Germany

PostPosted: Sat Oct 23, 2004 3:43 pm    Post subject: adsl internet freigabe Reply with quote

Hi
Ich habe 2 gentoo linux pcs
diese sind mit einem switch verbunden, an dem ebenfalls das adsl modem hängt ... einer der pcs geht mit adsl ins internet, was auch problemlos funktioniert. nur würde ich jetzt gerne wissen wie ich es hinbekomme, dass der andere pc über diesen ins internet kommt ... habe zu diesem thema bisher nur how to`s gefunden bei denen der server pc 2 netzwerkkarten hatte ... thx schonmal für die antworten
Back to top
View user's profile Send private message
jew.de
Apprentice
Apprentice


Joined: 25 Sep 2002
Posts: 226
Location: Frankfurt/Main

PostPosted: Sat Oct 23, 2004 3:53 pm    Post subject: Reply with quote

Hi,

bei mir ist der Aufbau exakt gleich.

Du kannst die normalen How-To's nutzen, routest halt nur über 1 NIC.

Wenn Du willst, kann ich Dir meine NAT/Firewall Config zuschicken -> PM!

Gruß, Tobi
_________________
http://www.jew.de
Back to top
View user's profile Send private message
Xe
Apprentice
Apprentice


Joined: 02 Sep 2004
Posts: 254
Location: Karlsruhe, Germany

PostPosted: Sat Oct 23, 2004 4:09 pm    Post subject: hi Reply with quote

jo allerdings kann ich mit den howtos die ich gefunden habe net so viel anfangen ... könntest du mir eventuell sagen was man für internet-freigabe nötig ist ?
Back to top
View user's profile Send private message
jew.de
Apprentice
Apprentice


Joined: 25 Sep 2002
Posts: 226
Location: Frankfurt/Main

PostPosted: Sat Oct 23, 2004 4:18 pm    Post subject: Re: hi Reply with quote

Xe wrote:
jo allerdings kann ich mit den howtos die ich gefunden habe net so viel anfangen ... könntest du mir eventuell sagen was man für internet-freigabe nötig ist ?


Den Kernel hast Du soweit schon vorbereitet?

Wenn ja, folge der Anleitung:


Das hier, wird Dein Start-Stop Skript.
Damit kannst Du per /etc/init.d/firewall start oder stop die Firewall starten oder stoppen.

Die Datei heißt /etc/init.d/firewall:
Code:

#!/sbin/runscript

depend() {
        need logger net
}

IPTABLES_SAVE="/usr/sbin/firewall_set"

start() {
        ebegin "Loading firewall rules and enabling IP-Forwarding..."
        if [ ! -f ${IPTABLES_SAVE} ]

        then
                einfo "Not starting firewall. First create some rules then run"
                einfo "${IPTABLES_SAVE}"
        else
                ${IPTABLES_SAVE}
        fi

        eend $?
}

stop() {
        ebegin "Flushing firewall and disabling IP-Forwarding..."
                # This way we don't forget to save changes
                iptables -F
                echo "0" > /proc/sys/net/ipv4/ip_forward
        eend $?
}


Als nächstes kommen die Regeln. Hierbei kann es sein, dass Du sie anpassen musst (IP, etc...)

Dateiname: /usr/sbin/firewall_set (wie in der /etc/init.d/firewall angegeben)
Code:

#! /bin/sh

##############################################################################

# Konstanten
EXT_DEV="ppp0"
INT_IP="192.168.1.1"
DONKEY="192.168.1.2"

##############################################################################
echo "Configuring firewall for $EXT_DEV, SNAT on $INT_IP and eDonkey Client on $DONKEY."
# Chains flushen
echo "Flushing..."
iptables -F
iptables -F -t nat

# IP forwarding aktivieren
echo "1" > /proc/sys/net/ipv4/ip_forward

# Default policies setzen
echo "Setting default policies..."
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

##############################################################################

# INPUT chain

echo "Generating INPUT chain..."
# Verbindungen nur akzeptieren, wenn sie zu einer bestehenden gehoeren...
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# ...oder von innen kommen
iptables -A INPUT -m state --state NEW -i ! $EXT_DEV -j ACCEPT

# Einige Aussnahmen:
#FTP
iptables -A INPUT -m state --state NEW -p tcp --dport 21 -j ACCEPT
#SSH
iptables -A INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT
#SMTP
#iptables -A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT
#HTTP/SSL
iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
#POP3
iptables -A INPUT -m state --state NEW -p tcp --dport 110 -j ACCEPT
#IMAP/SSL
#iptables -A INPUT -m state --state NEW -p tcp --dport 143 -j ACCEPT
#iptables -A INPUT -m state --state NEW -p tcp --dport 993 -j ACCEPT
#OPENVPN
#iptables -A INPUT -m state --state NEW -p udp --dport 5000 -j ACCEPT
#mldonkey
iptables -A INPUT -m state --state NEW -p tcp --dport 4080 -j ACCEPT
iptables -A INPUT -m state --state NEW -p tcp --dport 4662 -j ACCEPT

echo "Setting up for OpenVPN..."
# TUN/TAP FUER OPENVPN
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
iptables -A INPUT -i tap+ -j ACCEPT
iptables -A FORWARD -i tap+ -j ACCEPT
iptables -A POSTROUTING -t nat -o tun0 -j MASQUERADE
iptables -A POSTROUTING -t nat -o tun0 -j SNAT --to $INT_IP
iptables -A POSTROUTING -t nat -o tap0 -j MASQUERADE
iptables -A POSTROUTING -t nat -o tap0 -j SNAT --to $INT_IP

##############################################################################

# FORWARD chain
echo "Generating FORWARD chain..."

# Verbindungen nur akzeptieren, wenn sie zu einer bestehenden gehoeren...
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
# ...oder von innen kommen
iptables -A FORWARD -m state --state NEW -i ! $EXT_DEV -j ACCEPT

##############################################################################

# NAT und Masquerading
echo "Configuring SNAT..."

# NAT auf externem Device
iptables -A POSTROUTING -t nat -o $EXT_DEV -j MASQUERADE

# Source NAT auf interne IP
iptables -A POSTROUTING -t nat -o $EXT_DEV -j SNAT --to $INT_IP

##############################################################################

# Ports fuer Server in FORWARD chain oeffnen
echo "Configuring DNAT..."

# Port fuer Donkey auf $DONKEY
#iptables -A FORWARD -d $DONKEY -i $EXT_DEV -p tcp --dport 4662 -j ACCEPT
#iptables -A FORWARD -d $DONKEY -i $EXT_DEV -p udp --dport 4672 -j ACCEPT

##############################################################################

# Port forwarding

# Port 4662 --> $DONKEY:4662
#iptables -A PREROUTING -t nat -p tcp --dport 4662 -j DNAT --to $DONKEY:4662
#iptables -A PREROUTING -t nat -p udp --dport 4672 -j DNAT --to $DONKEY:4672

##############################################################################

# DROP an INPUT und FORWARD chains anhaengen

iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP


Nachdem Du die Firewall gestartet hast, bist Du in der Lage IP Forwarding zu betreiben und es werden auch nicht mehr alle Ports reingelassen.
Dein Router (Rechner der die DSL Verbindung aufbaut) ist dann ein NAT-Gateway.

Gruß, Tobi
_________________
http://www.jew.de
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum