LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2005, 06:15 AM   #1
sayyedanwar
LQ Newbie
 
Registered: Apr 2005
Location: India
Distribution: Fedora Core 3
Posts: 4

Rep: Reputation: 0
Question iptables script needed please help !!!!!


I have the following setup:
1. Linux PC with 2 Netwrk Card, one for local Network(192.168.1.10) , and other for Internet sharing (172.16.1.2, Gateway 172.16.1.1 (connected to ADSL Router)).
2. Linux has qmail, squirrelmail, squid, Samba, etc.
3. Windows NT (192.168.1.5) with Norton email scanner, which downloads the Mail from Internet (192.168.1.8 (Cisco Router - Hughes line)), scan the mails and forward it to Linux qmail.
4. Cisco Router (192.168.1.8), to which Hughes line is connected and it is purely used for emailing.
5. qmail sends out the mails to 192.168.1.8 i.e. router. Internet Connection on linux pc is used only for internet sharing via squid.

I have setup all the softwares. I need iptables script for above configuration. Please do it for me ASAP as I have to implement it at one of my customer place.

Thank you.
 
Old 04-04-2005, 07:03 AM   #2
musicman_ace
Senior Member
 
Registered: May 2001
Location: Indiana
Distribution: Gentoo, Debian, RHEL, Slack
Posts: 1,555

Rep: Reputation: 46
www.iptablesrocks.org/
http://www.faqs.org/docs/iptables/
http://krnlpanic.com/tutorials/iptables.php

Those are a few of my bookmarks and should be able to get your script up if you spend a day learning it.

I'm not trying to be mean, but isn't that why your customer would hire me. Maybe somebody hear has the spare time to write a company's firewall for free. I'll gladly help refine little pieces here and there, but asking us to create a custom firewall to secure your customer's network is going a little to far.
One of the rules says "Do ask people to do your homework." This sounds much like that only instead of school, it is for a business.
 
Old 04-04-2005, 07:24 AM   #3
sayyedanwar
LQ Newbie
 
Registered: Apr 2005
Location: India
Distribution: Fedora Core 3
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by musicman_ace
www.iptablesrocks.org/
http://www.faqs.org/docs/iptables/
http://krnlpanic.com/tutorials/iptables.php

Those are a few of my bookmarks and should be able to get your script up if you spend a day learning it.

I'm not trying to be mean, but isn't that why your customer would hire me. Maybe somebody hear has the spare time to write a company's firewall for free. I'll gladly help refine little pieces here and there, but asking us to create a custom firewall to secure your customer's network is going a little to far.
One of the rules says "Do ask people to do your homework." This sounds much like that only instead of school, it is for a business.
Thank you for ur reply musicman_ace, but i need the script urgently. If possible, please do it for me.

Thank you
 
Old 04-04-2005, 08:14 AM   #4
tangle
Senior Member
 
Registered: Apr 2002
Location: Arbovale, WV
Distribution: Slackware
Posts: 1,761

Rep: Reputation: 78
What he is trying to say is this: We are not here to do your work for you. We are nobodies slaves. If you need help with something most on here are glad to help. Help does not mean "do it for you". Plus, if you are making money on this, it would be only right for you to pay someone to do it.
 
Old 04-04-2005, 09:22 AM   #5
Darin
Senior Member
 
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024

Rep: Reputation: 45
I guess it's not explicitly stated in the rules when you sign up, so I'll refer you to a howto that one of the moderators has in his signature:
http://www.catb.org/~esr/faqs/smart-...ns.html#urgent

Basically, everyone here volunteers their time and I doubt you will find someone here who is willing to do for free all the work that you are likely being paid for.

I'm not sure how it is where you live, but in my town tech jobs are still not easy to come by, so if you would kindly provide your employer's contact information maybe someone who is capable of doing the job you were hired to do can apply for the position.
 
Old 04-04-2005, 09:26 AM   #6
sayyedanwar
LQ Newbie
 
Registered: Apr 2005
Location: India
Distribution: Fedora Core 3
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by tangle
What he is trying to say is this: We are not here to do your work for you. We are nobodies slaves. If you need help with something most on here are glad to help. Help does not mean "do it for you". Plus, if you are making money on this, it would be only right for you to pay someone to do it.
I'm extremely sorry for this. Actually I am using the forum for the first time. and i was very frustrated for this problem. Today itself I registered with 5 to 6 Forums and put the same question in similar fashion. Thank you for pointing this to me. And also my english is little weak.

I tried with script below. But it is not working.

iptables -t filter -F
iptables -t nat -F
iptables -t mangle -F


iptables -P FORWARD REJECT
iptables -A FORWARD -s 192.168.1.0/24 -d 0/0 -j ACCEPT
iptables -A FORWARD -s 192.168.1.0/24 -d 192.168.1.0/24 -j REJECT
iptables -A FORWARD -s 127.0.0.1 -d 192.168.1.0/24 -j REJECT
iptables -A FORWARD -s 192.168.1.0/24 -d 127.0.0.1 -j REJECT
iptables -A FORWARD -s 127.0.0.1 -o eth1 -j REJECT
iptables -A FORWARD -i eth1 -d 127.0.0.1 -j REJECT


iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth1 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -d 0/0 --dport 25 -d 192.168.1.8 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j REJECT
iptables -t nat -A POSTROUTING -s 0/0 -o eth0 -j REJECT
iptables -t nat -A POSTROUTING -s 0/0 -o eth0 -j REJECT


I typed above commands line by line. Other details are as follows
eth0=192.168.1.10 local Network
eth1=172.16.1.2 Connected DSL Router
192.168.1.8=Cisco Router Used send/receive mails.

eth0 and eth1 are installed in Fedora Core3. FC3 has qmail, squirrelmail,squid, Samba etc.

On Windows NT, Norton Mail Scanner downloads the Mails via Router (192.168.1.8), and forward it to Linux PC. qmail sends outgoing mail directly from router.

Second NIC (172.16.1.2) is used for Internet sharing via squid.

After using the above rules squid does not start.

Help will be appreciated.


Thank you
 
Old 04-04-2005, 03:50 PM   #7
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Here is an example script I saw on the net. This may help you abit....
Code:
 
#!/bin/sh
#
# The location of the iptables binary file on your system.
IPTABLES="/sbin/iptables"

# The Internet interface.
EXT="eth1"

# Out with the old stuff.
$IPTABLES -F
$IPTABLES -F INPUT
$IPTABLES -F OUTPUT
$IPTABLES -F FORWARD
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X

# These will setup our policies.
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT

# Use this for NAT or IP Masquerading.
echo 1 > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -A POSTROUTING -o $EXT -j MASQUERADE

# This rule will accept connections from local machines.
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A INPUT -s 192.168.1.0/24 -d 0/0 -p all -j ACCEPT

# This rule protects your fowarding rule.
$IPTABLES -A FORWARD -i $EXT -m state --state NEW,INVALID -j DROP

# Uncomment these for port forwarding. For example...
#$IPTABLES -t nat -A PREROUTING -i $EXT -p tcp --dport 25 -j DNAT --to 192.168.1.50
#$IPTABLES -t nat -A PREROUTING -i $EXT -p tcp --dport 53 -j DNAT --to 192.168.1.50
#$IPTABLES -t nat -A PREROUTING -i $EXT -p udp --dport 53 -j DNAT --to 192.168.1.50
# These two redirect a block of ports, in both udp and tcp.
#$IPTABLES -t nat -A PREROUTING -i $EXT -p tcp --dport 2300:2400 -j DNAT --to 192.168.1.50
#$IPTABLES -t nat -A PREROUTING -i $EXT -p udp --dport 2300:2400 -j DNAT --to 192.168.1.50
 
Old 04-05-2005, 02:00 AM   #8
sayyedanwar
LQ Newbie
 
Registered: Apr 2005
Location: India
Distribution: Fedora Core 3
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by homey
Here is an example script I saw on the net. This may help you abit....
Code:
 
#!/bin/sh
#
# The location of the iptables binary file on your system.
IPTABLES="/sbin/iptables"

# The Internet interface.
EXT="eth1"

# Out with the old stuff.
$IPTABLES -F
$IPTABLES -F INPUT
$IPTABLES -F OUTPUT
$IPTABLES -F FORWARD
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X

# These will setup our policies.
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT

# Use this for NAT or IP Masquerading.
echo 1 > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -A POSTROUTING -o $EXT -j MASQUERADE

# This rule will accept connections from local machines.
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A INPUT -s 192.168.1.0/24 -d 0/0 -p all -j ACCEPT

# This rule protects your fowarding rule.
$IPTABLES -A FORWARD -i $EXT -m state --state NEW,INVALID -j DROP

# Uncomment these for port forwarding. For example...
#$IPTABLES -t nat -A PREROUTING -i $EXT -p tcp --dport 25 -j DNAT --to 192.168.1.50
#$IPTABLES -t nat -A PREROUTING -i $EXT -p tcp --dport 53 -j DNAT --to 192.168.1.50
#$IPTABLES -t nat -A PREROUTING -i $EXT -p udp --dport 53 -j DNAT --to 192.168.1.50
# These two redirect a block of ports, in both udp and tcp.
#$IPTABLES -t nat -A PREROUTING -i $EXT -p tcp --dport 2300:2400 -j DNAT --to 192.168.1.50
#$IPTABLES -t nat -A PREROUTING -i $EXT -p udp --dport 2300:2400 -j DNAT --to 192.168.1.50
Thank you for this. I'll work on it and let you know
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Help needed with IPTABLES russoue Linux - Security 2 09-19-2005 03:21 AM
iptables are needed tekmorph Linux - Software 4 08-30-2004 07:32 PM
IPTABLES and 2.6.1 .. help needed ! svarreby Slackware 1 01-25-2004 07:01 PM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration