View previous topic :: View next topic |
Author |
Message |
Xe Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 02 Sep 2004 Posts: 254 Location: Karlsruhe, Germany
|
Posted: Sat Oct 23, 2004 3:43 pm Post subject: adsl internet freigabe |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
jew.de Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/d9bb02be3dc3c2bd83fe7.jpg)
Joined: 25 Sep 2002 Posts: 226 Location: Frankfurt/Main
|
Posted: Sat Oct 23, 2004 3:53 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Xe Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 02 Sep 2004 Posts: 254 Location: Karlsruhe, Germany
|
Posted: Sat Oct 23, 2004 4:09 pm Post subject: hi |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
jew.de Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/d9bb02be3dc3c2bd83fe7.jpg)
Joined: 25 Sep 2002 Posts: 226 Location: Frankfurt/Main
|
Posted: Sat Oct 23, 2004 4:18 pm Post subject: Re: hi |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|
|
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
|
|