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 11-08-2004, 11:14 AM   #1
Barca
LQ Newbie
 
Registered: Nov 2004
Location: Poland
Distribution: Slackware - best and only ;]
Posts: 29

Rep: Reputation: 15
Arrow Resending packets (routing)


First I would say "hello" to everybody, it's my first post here but I've read this forum many times already.
My Slack 10.0 is in LAN and have IP 192.168.0.100. I receive packets from 192.168.0.109 and I have to resend them to gateway (192.168.0.1). But, it's impossible to use "echo > 1 /proc/sys/net/ipv4/ip_forward" because packets from 192.168.0.109 as a destination IP haven't 192.168.0.1, but for example IP of google or any other place in the Internet.
So, I thought that iptables will be helpful. I tried many tricks with PREROUTING, REDIRECT etc. but no ones worked. Because I can't forward those packets to gateway, 192.168.0.109 hasn't access to the Internet.
Please, can you give me a iptables' rule or say why this for example doesn't work?

iptables -t nat -A PREROUTING -i eth0 -p tcp -s 192.168.0.109 -d 0/0 -j REDIRECT --to 192.168.0.1
iptables -t nat -A PREROUTING -i eth0 -p udp -s 192.168.0.109 -d 0/0 -j REDIRECT --to 192.168.0.1

I'm outta my mind already. Maybe you now some different solution, sth like fragrouter or what?

yours sincerely,
Barca
 
Old 11-08-2004, 12:29 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Welcome to LQ.

You would find it easier if both ethernet cards were on different subnets, this makes the routing much easier to manage.
 
Old 11-08-2004, 12:54 PM   #3
Barca
LQ Newbie
 
Registered: Nov 2004
Location: Poland
Distribution: Slackware - best and only ;]
Posts: 29

Original Poster
Rep: Reputation: 15
But the problem is, I have only one ethernet card (but I can change that if necessary) and I can't change subnet.
 
Old 11-08-2004, 06:20 PM   #4
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Rep: Reputation: 64
You may not need to use two separate NICs. You can use multiple sub-interfaces. Certainly this is common practice on Cisco routers that connect to VLANs, but I believe the prinicple would work in this situation as well.
Code:
# ifconfig eth0:1 192.168.1.27 up
Not sure what the limit of sub-interfaces under Linux is.
 
Old 11-08-2004, 10:13 PM   #5
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
IIRC -j REDIRECT can only redirect to the local machine, I'm not exactly sure what you're trying to achieve, but if changing the destination address is what you want then:
Code:
iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.9/24 -j DNAT --to-destination 192.168.0.1
 
Old 11-10-2004, 03:45 AM   #6
Barca
LQ Newbie
 
Registered: Nov 2004
Location: Poland
Distribution: Slackware - best and only ;]
Posts: 29

Original Poster
Rep: Reputation: 15
@Demonbane
root@mekka:/_maxtor/temp/icmp# ./iptables
Start
iptables: Invalid argument
Stop
?

@Thymox
Thanks for idea, I will be trying with that.

Do you think guys that command as "route" or "ip" will help me?
 
Old 11-12-2004, 09:03 PM   #7
cbe
LQ Newbie
 
Registered: Jul 2001
Posts: 19

Rep: Reputation: 0
The iptables command is not executed like this: ./iptables

If the command isnt in your path, run the command "whereis iptables" to see if this is installed on your system or run "which iptables" to see if its in your path (you may have to be root or fix your path).


On my machine it looks like this:

Code:
mybox> which iptables
/sbin/iptables

mybox> whereis iptables
iptables: /sbin/iptables /lib/iptables


once you know the path (/sbin/iptables) to your iptables command you can execute it like this:


mybox> /sbin/iptables -t nat -A POSTROUTING -p tcp -s 192.168.0.9/24 -j DNAT --to-destination 192.168.0.1


Hope this helps.
 
Old 11-13-2004, 03:24 PM   #8
Barca
LQ Newbie
 
Registered: Nov 2004
Location: Poland
Distribution: Slackware - best and only ;]
Posts: 29

Original Poster
Rep: Reputation: 15
Hehe, it's my fault. I have script which names "iptables" - and that's the reason I wrote "./iptables". Problem isn't in running iptables, but in finding right rule for the job.
 
  


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 Local Packets qs_tahmeed Linux - Networking 1 11-16-2005 10:30 PM
send packets with kernel routing and without kernel messing with headers bassdemon Programming 5 02-08-2005 06:29 PM
packets sent VS packets received fsasya Linux - Networking 0 07-18-2004 07:11 PM
encapsulating TCP packets in UDP packets... yoshi95 Programming 3 06-03-2004 02:53 PM
real routing under nat routing nothingmuch Linux - Networking 4 10-27-2003 03:11 PM

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

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