PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Erstes Startscript



dunervst
12.09.02, 17:42
Hi Leute,

ich habe noch nie vorher ein Startscript geschrieben, und schon beim ersten versuch klappt garnix. Kann mir hemand sagen was falsch ist.
Bitte helft mir.


#! /bin/bash

. /etc/rc.d/init.d/functions

int_iface=eth0;
ext_iface=eth1;
iptables=/sbin/iptables
int_net=192.168.0.0/255.255.255.0
ext_ip=`$IFCONFIG $ext_iface | grep inet | cut -d : -f 2 | cut -d " " -f 1`
ext_mask=`$IFCONFIG $ext_iface | grep Mask | cut -d : -f 4`
ext_net="$ext_ip/$ext_mask"



case "$1" in
start)
# Start Firewall.
echo -n "Starting Firewall: "
# Masquerading und IP-Forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe iptable_nat
$iptables -t nat -A POSTROUTING -o $ext_iface -j MASQUERADE
$iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

$iptables -P INPUT DROP
$iptables -P FORWARD DROP
$iptables -p OUTPUT ACCEPT


# FTP Client (Data Port)
# $iptables --append INPUT -p TCP -s 0/0 --source-port 20 -j ACCEPT

# FTP Server (Control)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 21 -j ACCEPT

# sshd (Secure Shell)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 22 -j ACCEPT

# smtp (öffentlicher smtp Server)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 25 -j ACCEPT

# DNS Server (domain name space)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 53 -j ACCEPT

# HTTP (Web Server)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 80 -j ACCEPT

# pop3 (pop3 empfang)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 110 -j ACCEPT

# imap (imap empfang)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 143 -j ACCEPT

# HTTPS (Secure Web Server)
# $iptables --append INPUT -p TCP -s 0/0 --destination-port 443 -j ACCEPT

# Akzeptieren aller internen Pakete
$iptables --append FORWARD -p tcp --in-interface $int_iface -j ACCEPT
$iptables --append FORWARD -p udp --in-interface $int_iface -j ACCEPT
$iptables --append FORWARD -p ALL --in-interface $int_iface -j ACCEPT
echo
;;
stop)
# Stop Firewall.
echo -n "Shutting down Firewall: "
echo 0 > /proc/sys/net/ipv4/ip_forward
$iptables -F
$iptables -t nat -f
$iptables -X
$iptables -t nat -X
echo
;;
restart)
$0 stop
$0 start
;;
status)
$iptables --list
;;
*)
echo "Usage: router {start|stop|restart|status}"
exit 1
esac

exit 0



Danke euch
Michael

anda_skoa
12.09.02, 22:12
Du kannst ja an verschienden Stellen ein
echo wasweissich >> /tmp/script.log
machen und dir danach ansehen, was alles drinnen steht.

Außerdem hast du ein Leerzeichen zwischen ! und /bin/bash.

Ciao,
_

jotpe
12.09.02, 22:15
außerdem ein leerzeichen zwischen '.' und '/etc/rc.d/init.d/functions'

anda_skoa
12.09.02, 22:28
das ist in Ordnung, wenn er das script sourcen will.
Und da der Pfad mit /etdc anfängt, nehme ich das mal an :)
(./etc würde nicht viel Sinn machen)

Ciao,
_