LinuxQuestions.org
Review your favorite Linux distribution.
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 01-06-2004, 10:55 PM   #1
caremaker
LQ Newbie
 
Registered: Jan 2004
Posts: 7

Rep: Reputation: 0
iptables masquerading troubles


I'm running into an odd issue with a simple masqueraded network. I've browsed the posts here and the internet but can't seem to find anyone with a similiar issue.

My network setup is as follows: I have a cable modem plugged into a windows XP machine with 2 NICs. 1 receiving the internet IP and the other an internal LAN address (192.168.0.1) going to a hub with 2 other machines (192.168.0.2 and .3). I have just recently replaced the XP "router" with a linux box, pulled 1 of the interfaces out of the XP machine and reassigned its remaining NIC with the internal address to 192.168.0.4. My linux machine now has 2 interfaces, 1 with the external IP (assigned by my ISPs dhcp server) and the other with a 192.168.0.1 address.

I have applied the basic masquerading rules:

# start rules
iptables -F
iptables -t nat -F
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
# stop rules

eth0 = external dynamic IP (24.170.170.xxx)
eth1 = lan IP (192.168.0.1)

I'm able to access the internet from my linux machine but cannot from my internal lan. However, I can ping my internal machines from my linux box and vise versa. I cannot ping on interface from the other though. For example, executing:

ping -I eth1 207.69.188.185

I get a Destination Host Unreachable.

However, pinging the same IP from eth0 returns results - so its definitely got a connection to the internet (I'm able to lynx to google). I'm also not able to ping eth0 from eth1 (same results).

Thought it might be a routing issue but everything looked fine. Default gateway is set when I bring up eth0. When I try to add a route for eth1 to use the gateway dhcp set in my /etc/resolve.conf (when I brought up eth0) I get a "Network is unreachable" error.

So I did a traceroute to see what my first hop was. Interesting it was a private IP: 10.107.192.1. However, the IP assigned to me when I bring up eth0 is NOT a private IP (24.170.170.186 currently).

<sigh>

XP seems to have no trouble sharing the connection but iptables is causing a log of frustration.

I'd be happy to provide any additional information you might need. Not quite sure where to go from here...

Thanks for any help!
 
Old 01-07-2004, 12:08 AM   #2
balaji2001com
Member
 
Registered: Jun 2003
Location: Chennai,India
Distribution: Almost all the flavours of linux
Posts: 39

Rep: Reputation: 15
You are getting too technical.Try to think simple.The hits from the internal network come to your gw (ie)internal ip.From there you have not routed the traffic to the external ip.(ie)from eth1 to eth0.Without which the packets comming inside your gateway will not know what is to be done.Correct me if iam wrong.
 
Old 01-07-2004, 07:13 AM   #3
caremaker
LQ Newbie
 
Registered: Jan 2004
Posts: 7

Original Poster
Rep: Reputation: 0
I've tried adding that route. Unless I am trying to add a route to the wrong IP....

What exactly should my route be?

eth0=24.170.170.186
eth1=192.168.0.1
default gateway=207.69.188.185

When I try to add a route from 192.168.0.0 traffic to 207.69.188.185 I get a "network is unreachable" error.
 
Old 01-07-2004, 02:17 PM   #4
dubman
Member
 
Registered: Jan 2003
Distribution: Redhat 9, Fedora Core 1, Suse 8
Posts: 188

Rep: Reputation: 30
Have you enabled IPv6 forwarding?

here is a good site for you:
http://eressea.pikus.net/~pikus/plug...all/page0.html
 
Old 01-07-2004, 03:34 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
I have a line like this in my firewall which may be of use to you.


# This rule will accept connections from local machines.
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A INPUT -s 192.168.0.0/24 -d 0/0 -p all -j ACCEPT
 
Old 01-07-2004, 04:27 PM   #6
Dewar
Member
 
Registered: Sep 2003
Location: Washington State
Distribution: SuSE 8.0, SuSE 9.0, Slack 9.1
Posts: 90

Rep: Reputation: 15
As far as gateways go.... Your default gateway on the firewall should be set via DHCP from your internet provider. It should be an address in the same subnet as your external ip address. The default gateway for all your internal machines should be the firewall's internal address.

As far as iptables goes.... What is contained in your FORWARD table (iptables -L FORWARD) Packets coming in one interface and out the other hit the FORWARD table, so if the default is deny, you might be getting blocked there.

-Dewar
 
Old 01-07-2004, 06:21 PM   #7
caremaker
LQ Newbie
 
Registered: Jan 2004
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you all for your replies! I really appreciate it.

I actually got it working. Kinda embarrassed...it turned out to be dns issues on my internal machines. Figured it out by noticing I could ping machines on the internet by their IP from my local machines. That was a giveaway.

Still don't know quite why I can't ping "pingable" internet machines from eth1 (my internal 192.168.0.1 interface) but can from machines within my lan. Oh well...not too worried about that.

Thanks again!
 
  


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 : masquerading not possible iamtux Linux - Networking 3 06-04-2005 11:32 PM
squid and iptables masquerading egyptian Linux - Security 1 09-05-2004 04:31 AM
IP Masquerading (with iptables) and Planetside Milkman00 Linux - Networking 4 06-06-2003 09:12 AM
Iptables Masquerading GOLDF1NG3R Linux - Security 3 11-10-2001 11:51 PM
Iptables Masquerading GOLDF1NG3R Linux - Networking 4 11-01-2001 04:34 AM

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

All times are GMT -5. The time now is 12:54 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