LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-20-2004, 02:03 PM   #1
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Rep: Reputation: 15
Unhappy Forwarding connection using the same subnet IPs


I have 2 computers.
One is connecting to the internet through gate 192.168.1.1.
It is also supposed to forward connection to and from the second computer.

I wanted all interfaces to have IP starting with 192.168.1.
Ideally like this:

PC0 PC1 PC2
gate eth0 eth1 eth0
192.168.1.1 192.168.1.31 192.168.1.32 192.168.1.33


I used the following commands to do this.

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.33 -j SNAT --to 192.168.1.31

unfortunately it doesn't work.

I know that when I change:
192.168.1.32 in to 192.168.0.32
and
192.168.1.33 in to 192.168.0.33

routing is just fine

Is there any way to have all IP starting with 192.168.1. ??? (the gateway accepts only this kind of IP)
Otherwise I have to change IP of the second computer when I connect to the gateway directly or when I run WindowXP on the PC1 which is using bridging for sharing connection.

Andrzej
 
Old 03-20-2004, 02:10 PM   #2
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Original Poster
Rep: Reputation: 15
once again schame of of my network. (previous posting is not clear)

PC0 PC1 PC2
gate eth0 eth1 eth0
192.168.1.1 192.168.1.31 192.168.1.32 192.168.1.33
 
Old 03-20-2004, 02:17 PM   #3
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Original Poster
Rep: Reputation: 15
sorry. once again.

PC0______________________PC1______________________PC2
gate_______________eth0___________eth1______________eth0
192.168.1.1______192.168.1.31____192.168.1.32_________192.168.1.33
 
Old 03-24-2004, 04:12 PM   #4
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Original Poster
Rep: Reputation: 15
Anyone

 
Old 04-07-2004, 06:48 AM   #5
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Original Poster
Rep: Reputation: 15
anyone??
 
Old 04-07-2004, 09:21 AM   #6
bentman78
Member
 
Registered: Mar 2003
Location: Washington DC, USA
Distribution: Redhat
Posts: 212

Rep: Reputation: 30
when you configure your iptables to route the network are you putting 192.168.0.0/24 or 192.168.1.0/24.

If you are using a 24 bit subnet mask, the first three octets are your network ID. You have to make sure you put the correct net ID in.
 
Old 04-07-2004, 09:22 AM   #7
bentman78
Member
 
Registered: Mar 2003
Location: Washington DC, USA
Distribution: Redhat
Posts: 212

Rep: Reputation: 30
do this:
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j SNAT --to 192.168.1.31
 
Old 04-11-2004, 09:32 AM   #8
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Original Poster
Rep: Reputation: 15
thank you bentman78. but it didn't work.
I just wanted to route one particular IP 192.168.1.33.
that is why I used:
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.33 -j SNAT --to 192.168.1.31
with what you suggested:
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j SNAT --to 192.168.1.31
it is supposed to route the whole network instead of only one IP. It would be fine with me, but unfortunatelly it doesn't work neither.

Andrzej
 
Old 04-13-2004, 10:02 AM   #9
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Original Poster
Rep: Reputation: 15
anyone ??
 
Old 04-13-2004, 10:12 AM   #10
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
why do u ask hard question?
how is your pc1 routing table?
what "route -n" shows in pc1?
 
Old 04-26-2004, 03:52 PM   #11
superandrzej
Member
 
Registered: Nov 2003
Posts: 63

Original Poster
Rep: Reputation: 15
bash-2.05b# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 1 0 0 eth0
 
Old 04-26-2004, 04:29 PM   #12
Freeman-Jo
Member
 
Registered: Apr 2004
Location: Internet
Distribution: Gentoo
Posts: 30

Rep: Reputation: 15
I'm not good at this routing thing, but I think it might help, you provide more info, like error message when pinging, ftp, web from all three machine.
 
Old 04-27-2004, 02:05 AM   #13
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
i think when u try to ping it it will prefer eth0 interface to reach 192.168.1.33 .
can u ping pc2 from pc1?
try to add route:
/sbin/route add -host 192.168.1.33 dev eth1

if it still doesnt work, u must prefer bridge or routing.


by the when u change 192.168.1.33/24 to 192.168.0.33/24 routing will work fine, and 192.168.0.33/24 (pc2) can also access internet. apply SNAT rule for 192.168.0.33/24 so your gateway will see only 192.168.1.31 ip. it wont understand if ip of pc2 is 192.168.0.33/24. it just will see 192.168.1.31.
iptables -t nat -A POSTROUTING -s 192.168.0.33 -j SNAT --to 192.168.1.31
 
  


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
X forwarding through a convoluted connection Jessard Linux - Networking 4 07-22-2005 12:27 AM
iptables/forwarding connection phatboyz Linux - Networking 0 01-05-2005 12:02 PM
how to define a specific range of IPs and/or multiple IPs in an iptables rule?... TheHellsMaster Linux - Security 9 09-20-2004 10:06 AM
howto Xwin forwarding from a remote subnet? inki Linux - Security 2 01-16-2002 08:16 AM
Bridging subnet over tcp-connection ? lhm Linux - Networking 0 06-30-2001 04:38 PM

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

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