Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Iptables advanced routing
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
mycroes
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 110
Location: Netherlands

PostPosted: Tue Jun 03, 2003 4:38 pm    Post subject: Iptables advanced routing Reply with quote

Just to introduce my situation: I'm using windows 2000 on this pc. This pc is connected to my Gentoo pc that will be server for my web page soon. The Gentoo pc is connected to a hub through another NIC, and on the hub there are several other pc's (running windows).
I managed to get all my pc's/NICs on the same subnet, and I'm using iptables with ipv4_forwarding to have internet on my windows 2000 pc. Now the problem is I want to have acces to the other pc's in the network (that are connected to the hub). I can see them in network neigboorhood, but I can't acces them.

The iptables commands I used on my Gentoo pc are:
iptables -A POSTROUTING -t nat -s 192.168.0.54 -o eth0 -j MASQUERADE
iptables -A POSTROUTING -t nat -s 192.168.0.1/24 -o eth1 -j MASQUERADE

192.168.0.54 is my windows 2000 pc, eth1 is connected to the 2000 pc, eth0 is going to the hub with the other pc's.

Am I doing anything wrong or can't it be done what I want?
Thnx in advance.
Greetings,

Michael
_________________
In a world without walls or fences we don't need windows or gates
Back to top
View user's profile Send private message
DefconAlpha
Apprentice
Apprentice


Joined: 25 Feb 2003
Posts: 151
Location: Alabama

PostPosted: Tue Jun 03, 2003 5:08 pm    Post subject: Masquerading Reply with quote

I'm not exactly sure why you have the win2k box plugged into the hub (dmz or something?) but you won't need to use masquerading. You will want to bridge the two networks together. I think that you will want something on the order of

Code:
iptables -t nat -A PREROUTING -i win2knic -o lannic -J SNAT


though i'm sure that this specific command won't work. I have all of the documentation at work if you can't find any good tutorials on netfilter bridging (i can't for the life of me find that tutorial... good thing i printed it out :)

Regardless of the command you will have to bridge the two subnets together, not masquerade them...

[edit]
So I don't have a short term memory. At all. :) Keep me posted on what you find out, and i will get the docs as soon as i can (latest tomorrow at work)
_________________
In the end, the love you get is equal to the love you make
--John Lennon & Paul McCartney (The End - Abbey Road,


Last edited by DefconAlpha on Tue Jun 03, 2003 9:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
mycroes
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 110
Location: Netherlands

PostPosted: Tue Jun 03, 2003 5:15 pm    Post subject: iptables Reply with quote

the Gentoo pc is connected to the hub, the win2000 pc is only connected to the gentoo pc... I'll try to do some with the prerouting command.
Thnx anyway :D
Greetings,

Michael
_________________
In a world without walls or fences we don't need windows or gates
Back to top
View user's profile Send private message
uzik
Apprentice
Apprentice


Joined: 17 Apr 2003
Posts: 257

PostPosted: Tue Jun 03, 2003 7:07 pm    Post subject: Reply with quote

I would think you'd want to set rules for the "FORWARD" chain
to forward traffic from one NIC to the other on the gentoo box.
for file sharing you need to allow traffic on ports 137 and 139 through
from one nic to the other. I've never tried file sharing on separate
subnets, but I thought it would work fine. I don't think you need
masquerade
Back to top
View user's profile Send private message
mycroes
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 110
Location: Netherlands

PostPosted: Tue Jun 03, 2003 7:17 pm    Post subject: What you don't seem to understand... Reply with quote

The windows 2000 pc and the other pc's in the hub are on the same subnet (192.168.0.x, subnet mask 255.255.255.0). I think that I indeed may be searching for forwarding, but could you please give a (working) example (the prerouting example by DefconAlpha wasn't working :roll: )?
Greetings,

Michael
_________________
In a world without walls or fences we don't need windows or gates
Back to top
View user's profile Send private message
uzik
Apprentice
Apprentice


Joined: 17 Apr 2003
Posts: 257

PostPosted: Tue Jun 03, 2003 10:21 pm    Post subject: Re: What you don't seem to understand... Reply with quote

mycroes wrote:
The windows 2000 pc and the other pc's in the hub are on the same subnet (192.168.0.x, subnet mask 255.255.255.0). I think that I indeed may be searching for forwarding, but could you please give a (working) example (the prerouting example by DefconAlpha wasn't working :roll: )?
Greetings,

Michael


I can't guarantee this will work for you but I'll give it a try:

# from eth0 to eth1
iptables -A FORWARD --sport 137:139 -i eth0 -o eth1 -j ACCEPT

# from eth1 to eth0
iptables -A FORWARD --sport 137:139 -i eth1 -o eth0 -j ACCEPT

I dont have time to solve this problem for you.
Find the "how to" on iptables, it will help with this.
I'm not sure if you need input and output rules in
addition to the forward rules, but I thought not.
Port 137 is for file sharing, port 139 is for the network
neighborhood announcement packets
Back to top
View user's profile Send private message
DefconAlpha
Apprentice
Apprentice


Joined: 25 Feb 2003
Posts: 151
Location: Alabama

PostPosted: Wed Jun 04, 2003 2:46 pm    Post subject: Bridge Reply with quote

Well, i have done some hunting and i think that the easiest thing to do would be to make a pseudo-bridge. The advanced linux routing project has some dox on it, but basically here's what you should do to test it out:

1: flush out all of your iptables rules (may not even need iptables for this)
2: create routes so that gentoo box can talk to either pc (already done from what it seems)
3: echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/eth1/proxy_arp
echo 1 > /proc/sys/net/ipv4/ip_forward (if not already on)
4: run the 'arping' tool

if that doesn't work well, issue
echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind so you can send out unsolicted arp messages.

Give this a shot, i'm curious to know if it works (i will probably want to use something like this)
_________________
In the end, the love you get is equal to the love you make
--John Lennon & Paul McCartney (The End - Abbey Road,
Back to top
View user's profile Send private message
mycroes
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2003
Posts: 110
Location: Netherlands

PostPosted: Wed Jun 04, 2003 6:03 pm    Post subject: Thnx but... Reply with quote

I think it would work with just forwarding ports 137 and 139, but I ran into another problem. Windows 2000 only seems to work with gateways ending with a .1, allthough it worked for a few days it stopped working yesterday so I'm on a different subnet now... I'll try to fix it later and then gonna do this all over again, I think I can get there without any more help now. Thnx all :D
Greetings,

Michael
_________________
In a world without walls or fences we don't need windows or gates
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum