Code: Alles auswählen
#!/bin/bash
INET_HOST=123.45.67.89
function ipt_accept_all() {
# Alles löschen
iptables -F
iptables -t nat -F
iptables -t mangle -F
# Filter auf ACCEPT
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# NAT auf ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
# Mangle auf ACCEPT
iptables -t mangle -P INPUT ACCEPT
iptables -t mangle -P FORWARD ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P POSTROUTING ACCEPT
}
function ipt_masq_eth0() {
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
}
function ipt_ssh-server() {
SSH_HOST=192.168.10.88
SSH_PORT=22
INET_PORT=22000
iptables -t nat -A PREROUTING -p tcp -d $INET_HOST --dport $INET_PORT \
-j DNAT --to-destination $SSH_HOST:$SSH_PORT
}
function ipt_web-server() {
WEB_HOST=192.168.10.88
WEB_PORT=8080
INET_PORT=80
iptables -t nat -A PREROUTING -p tcp --dst $INET_HOST --dport $INET_PORT \
-j DNAT --to-destination $WEB_HOST:$WEB_PORT
iptables -t nat -A POSTROUTING -p tcp --dst $WEB_HOST --dport $WEB_PORT \
-j SNAT --to-source 192.168.10.1
iptables -t nat -A OUTPUT -p tcp --dst $INET_HOST --dport $INET_PORT \
-j DNAT --to-destination $WEB_HOST:$WEB_PORT
}
ipt_accept_all
ipt_masq_eth0
ipt_ssh-server
ipt_web-server
Ich hab das genau so gemacht, wie das hier steht:
http://iptables-tutorial.frozentux.net/ ... DNATTARGET
Weis jemand rat??
gHeift