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 12-01-2004, 06:10 PM   #1
stakhous
Member
 
Registered: May 2003
Location: PA
Posts: 82

Rep: Reputation: 15
Having problems routing between two interfaces...


First off, I searched through the forums and found multiple related threads, but they were unable to solve my problem.

By using iptables, i want to be able to surf the internet from my XP machine.

Two Computers: XP Pro and RH 9.0 w/ iptables 1.2.7a (this is going to be the router)


XP interface is configured as 10.51.1.100 with a gateway of 10.51.1.1.

RedHat's two inferfaces are as follows:

eth0 Link encap:Ethernet HWaddr 00:0C:41:1EC8
inet addr:192.168.1.107 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3614 errors:0 dropped:0 overruns:0 frame:0
TX packets:2762 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1792325 (1.7 Mb) TX bytes:313202 (305.8 Kb)
Interrupt:11 Base address:0x2c00

eth1 Link encap:Ethernet HWaddr 00:40:33:A3:37:0F
inet addr:10.51.1.1 Bcast:10.51.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2917 errors:1 dropped:0 overruns:0 frame:0
TX packets:2513 errors:1 dropped:0 overruns:0 carrier:1
collisions:0 txqueuelen:100
RX bytes:249613 (243.7 Kb) TX bytes:588105 (574.3 Kb)
Interrupt:9 Base address:0x7800


I have enabled ip_forward, so I am able to ping 192.168.1.107 from my XP machine(10.51.1.100)

I can't figure out how to configure iptables to allow Web access from my XP machine. I have tried...

iptables -t nat -A POSTROUTING -s 10.51.1.0/24 -o eth1 -j SNAT --to 192.168.1.1


I really dont know what else to try, I have read many iptable tutorials but none clearly explain how to set up forwarding in this scenario. Any help would be much appreciated, if not links are just as good.

Cheers
 
Old 12-02-2004, 02:41 AM   #2
bastard23
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 275

Rep: Reputation: 30
Change
iptables -t nat -A POSTROUTING -s 10.51.1.0/24 -o eth1 -j SNAT --to 192.168.1.1
to
iptables -t nat -A POSTROUTING -s 10.51.1.0/24 -o eth0 -j SNAT --to 192.168.1.107

Is 192.168.1.1 a typo?
This rule needs to happen on the interface (eth0) that is towards the internet.
 
Old 12-02-2004, 09:34 PM   #3
stakhous
Member
 
Registered: May 2003
Location: PA
Posts: 82

Original Poster
Rep: Reputation: 15
No luck! But thanks for the quick reponse. I"m still reading up on iptables hoping I can figure something out. Right now I have arno's iptables set up, which NAT works fine.


Cheers
 
Old 12-02-2004, 11:30 PM   #4
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
Where is the interface that connects to the internet?
 
Old 12-03-2004, 12:58 PM   #5
stakhous
Member
 
Registered: May 2003
Location: PA
Posts: 82

Original Poster
Rep: Reputation: 15
Sorry, i should have stated that.

eth0 connects to another router, which then connects to the Internet.

Thanks again
 
Old 12-03-2004, 03:03 PM   #6
TigerOC
Senior Member
 
Registered: Jan 2003
Location: Devon, UK
Distribution: Debian Etc/kernel 2.6.18-4K7
Posts: 2,380

Rep: Reputation: 49
You need to have ip-masquerading installed. The gateway for the xp box will then be ip address of the ethernet card connected to the xp box. i.e. if eth0 is connected to the modem/router the gateway for the RH box will be that ip address and if eth1 is connected to the xp box the gateway will be the ip address if eth1.
 
Old 12-03-2004, 03:44 PM   #7
zatriz
Member
 
Registered: Aug 2003
Location: Seattle, Wa
Distribution: Fedora,Trustix,Debian
Posts: 290

Rep: Reputation: 30
One of the easiest ways to get this working would be to install a firewall package like shorewall or firehol or some other one of your choice where all you have to tell it is your interfaces and it would configure everything else. I have your exact same setup with shorewall installed in all of 5 minutes.
 
Old 12-03-2004, 04:35 PM   #8
vald
LQ Newbie
 
Registered: Sep 2004
Location: Bulgaria
Distribution: Fedora
Posts: 14

Rep: Reputation: 0
by default redhat have preinstalled some firewall rules in iptables, so at first you should flush chains and build your own ruleset

try that:
iptables -P FORWARD ACCEPT - to set to ACCEPT forward's policy
iptables -F - to flush all chains
iptables -t nat -A POSTROUTING -s 10.51.1.0/24 -o eth0 -j SNAT --to 192.168.1.107

of cource you should set XP's default gateway to 10.51.1.1
 
Old 12-05-2004, 06:10 PM   #9
stakhous
Member
 
Registered: May 2003
Location: PA
Posts: 82

Original Poster
Rep: Reputation: 15
OMG, it worked!

Thanks a million vald, I have been trying to figure out this problem for a month now. Out of all the iptable tutorials I have read, nothing has worked.

Thanks again


Stakhous
 
  


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
Routing between interfaces? cryptical Linux - Networking 13 08-18-2004 07:29 AM
routing problems hakiro Linux - Networking 4 07-20-2004 09:50 AM
Routing Between Virtual Interfaces on Web Server Louie55 Linux - Networking 2 02-20-2004 09:17 AM
Problem with routing between interfaces Kostko Linux - Networking 6 12-01-2003 01:47 PM
Setting of Interfaces and Routing Table swmok Linux - Networking 1 07-31-2003 06:44 AM

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

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