LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-12-2006, 03:26 AM   #1
mrweirdo
LQ Newbie
 
Registered: Feb 2004
Posts: 21

Rep: Reputation: 15
cant get iptables script to work


OK I have done tons of reading on using iptables. So I have came up with a basic script. I am runing ubuntu server dapper(aka base install + no gui) but for the life of me I cant figure out why my iptable script will not work. I can still sites online from the box but internaly from other computers on the lan I cant access or ping any external sites.

I know this is not the most secure script yet but I want to make sure I can get this working before i add things like loging in.

Basicly what its suposed to do is share an internet conection on the internal lan eth1
external lan is eth0.

Code:
#!/bin/sh
IPTABLES='/sbin/iptables'

# enable ip forwarding in the kernel
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward

#------------------------------------------------------------------------------
# Cleanup.
#------------------------------------------------------------------------------

# Delete all rules.
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F

# Delete all (non-builtin) user-defined chains.
$IPTABLES -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X

# Zero all packet and byte counters.
$IPTABLES -Z
$IPTABLES -t nat -Z
$IPTABLES -t mangle -Z

#------------------------------------------------------------------------------
# Filter policies:
#------------------------------------------------------------------------------

# Default policies: drop everything.
$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -P OUTPUT DROP

# Define Input Rules:
$IPTABLES -A INPUT -i eth1 -j ACCEPT
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A INPUT -i eth0 -f -j DROP
$IPTABLES -A INPUT -d 127.0.0.0/255.0.0.0 -i eth0 -j DROP

# Define Forward Rules:
$IPTABLES -A FORWARD -i eth1 -o eth0 -m state --state NEW,ESTABLISHED -j ACCEPT

# Define Output Rules:
$IPTABLES -A OUTPUT -o eth1 -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT
$IPTABLES -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp -m tcp --dport 53 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp -m tcp -m multiport --dports 67,68 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp -j ACCEPT

#------------------------------------------------------------------------------
# Nat policies:
#------------------------------------------------------------------------------

# Default policies: allow everything.
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT

# Define Postrouting Rules:
$IPTABLES -t nat -A POSTROUTING -o eth0 -j MASQUERADE

#------------------------------------------------------------------------------
# Mangle policies: 
#------------------------------------------------------------------------------

# Default policies: allow everything.
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P INPUT ACCEPT
$IPTABLES -t mangle -P FORWARD ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT
$IPTABLES -t mangle -P POSTROUTING ACCEPT
Nothing is wrong with the network config but as far as the rest of the setup goes for reference:
eth1:
ip:192.168.1.11
subnet: 255.255.255.0
lan client pc
ip: 192.168.1.15
subnet: 255.255.255.0
gateway: 192.168.1.11
dns1: 68.87.76.178
dns2: 68.87.66.196

Does anyone know why the internal lan client cant access the net or ping websites on the net while the ubuntu box can still ping sites on the net? and how I might fix this script?
 
Old 06-12-2006, 03:53 AM   #2
mrweirdo
LQ Newbie
 
Registered: Feb 2004
Posts: 21

Original Poster
Rep: Reputation: 15
got it working i had the forward rule devices backwords

Last edited by mrweirdo; 06-12-2006 at 04:11 AM.
 
  


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
iptables script BACTRATE Mandriva 1 06-24-2004 05:34 AM
IPTABLES script help closer Linux - Networking 18 11-04-2002 09:48 AM
iptables script buttnutt Linux - Security 17 04-20-2002 09:55 AM
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 - Security

All times are GMT -5. The time now is 01:43 AM.

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