nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

will this work?

This is a discussion on will this work? within the Shell scripting forums, part of the Development/Scripting category; hi nixcraft, it is obvious that i am really new to linux so i will paste this script that i ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 03-28-2007, 01:02 PM
Junior Member
 
Join Date: Mar 2007
Posts: 1
Rep Power: 0
mudfish
Default will this work?

hi nixcraft,

it is obvious that i am really new to linux so i will paste this script that i have modified for you to analyze it(plcoz i dont wanna mess out with my linux gateway again and again.i know i am really pissing you off right now but i guess I just want to LEARN.

Code:
#!/bin/sh
# ------------------------------------------------------------------------------------
# See URL: http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html
# (c) 2006, nixCraft under GNU/GPL v2.0+
# -------------------------------------------------------------------------------------
# squid server IP
SQUID_SERVER="192.168.1.1"
# Interface connected to Internet
INTERNET="eth1"
# Interface connected to LAN
LAN_IN="eth0"
# Squid port
SQUID_PORT="3128"

# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
#############################################################################
# this part was copied on http://www.cyberciti.biz/faq/iptables-open-ftp-port-21/
# and REPLACE the -d option with INTERNET to make it work??
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d INTERNET --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s INTERNET --sport 21 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d INTERNET --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp -s INTERNET --sport 1024:65535 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s INTERNET --sport 20 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d INTERNET --dport 20 -m state --state ESTABLISHED -j ACCEPT
#############################################################################
#forward ftp port 21  to ftp server 192.168.1.250(this is what nixcraft suggested)
iptables -t nat -A PREROUTING -i INTERNET -p tcp --dport 21 -j DNAT --to-destination 192.168.1.250
#############################################################################
# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# unlimited access to LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT
# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
# if it is same system
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
# DROP everything and Log it
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP

i have also added the following lines on my squid.conf file

acl ftp proto FTP
http_access allow ftp

what do you think about the script ive modified?is it okay?how about the iptable rules?is it in order?do you think i would be able to connect to my ftp server now when im outside my network?my ftp server(cerberu is running on a windows 2003 machine(inside my network) with firewall disabled.

i will not touch anything on my linux gateway coz i would be waiting for your reply first

thanks
Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Do you use Linux to do your everyday work? charvi The Hangout 12 10-10-2008 07:01 PM
old server.error-handler-404 doesn't work anymore muks Web servers 5 08-29-2007 02:29 PM
Linux usb keyboard does not work jerry Linux software 3 04-05-2006 10:21 PM


All times are GMT +5.5. The time now is 09:05 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36