LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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
 
LinkBack Search this Thread
Old 02-16-2006, 09:28 AM   #1
madhavann
LQ Newbie
 
Registered: Jan 2006
Distribution: FEDORA CORE 3
Posts: 8

Rep: Reputation: 0
Forwarding packets between two NIC


hello all,
i have a linux machine with two ethernet cards and i have to forward the packets that are received on one NIC to the other NIC at the kernel level....
Can this be done...
I had tried it by modifying the ethernet header information of the packet by using the hard_header() function of net_device structure. I have intercepted the packets at the IP layer of the network stack with netfilter. I had used the function but the packet is not forwarded. I want to know the exact location of the implementation of the hard_header()in the kernel. If anyone knows more info kindly provide me with them
Is there any other way of doing it in the kernel stack
I thank the ideas in advance


madhavan
 
Old 02-16-2006, 10:36 AM   #2
jschiwal
Moderator
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,263

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
Do you want something like a transparent firewall?
http://www.securityfocus.com/infocus/1737

http://linux-net.osdl.org/index.php/Bridge

Last edited by jschiwal; 02-16-2006 at 10:42 AM.
 
Old 02-16-2006, 11:21 AM   #3
soup
Member
 
Registered: Jun 2003
Location: London, Ontario
Distribution: Ubuntu, Slackware, FreeBSD
Posts: 61

Rep: Reputation: 15
I dont know about hard_header() but I'm pretty sure you can do what you want just by using iptables - which i think controls netfilter. Just add rules to the input output and forward chains.
 
Old 02-16-2006, 07:40 PM   #4
jschiwal
Moderator
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,263

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
Your original message doesn't indicate what you are trying to accomplish.
Routing packets between interfaces based on what?

Is each interface connected to a different subnet, or are you wanting to perform NAT translation, or do you want to install a bridge or use your computer as a switch, or as a router w/IDS protection.

A bridge or switch will will work at a different layer, using the MAC address of connected hosts. A netfilter based firewall will normally base its rules on the IP addresses of the hosts. As Soup mentioned, the ip_tables command is used to interface with netfilter in kernel.
 
Old 02-16-2006, 11:37 PM   #5
madhavann
LQ Newbie
 
Registered: Jan 2006
Distribution: FEDORA CORE 3
Posts: 8

Original Poster
Rep: Reputation: 0
hi jschiwal,
the ethernet cards are connected two different sub networks.
eth0 is connected to the class B domain subnetwork
eth1 is connected to the class A domain subnetwork
what i need to do is
every packet that is received on the eth0 must be directed to the eth1 and vice versa. the important thing is that the packet contents should not be modified by the linux network stack
suggest a way of doing it friends
madhavan
 
Old 02-17-2006, 08:06 AM   #6
jschiwal
Moderator
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,263

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
You could simply have everything plugged into a hub.

If you want certain traffic routed, the routing table is usually set up for you when you set up the IP and netmasks on the two NICs. If your Linux host is what connects these two subnets (a gateway), then the address of your respective NIC card will need to be entered as the default gateway for other hosts. If you want your linux host to be a bridge, you will need to set up and configure a bridge device. A bridge works by looking at the MAC addresses.

It almost sounds as if you don't want to use subnetting to begin with.
The purpose of subnetting is to segregate the network. A gateway will go further and reduce traffic on the wire (important with hubs) and prevent traffic from unauthorized hosts from passing through.

There is a book titled "The Network Administration Guide", referred to as the NAG guide, available online at www.tldp.org.
Also, the man pages for "route" "ip" and "iptables" may be helpful.

Last edited by jschiwal; 02-17-2006 at 08:11 AM.
 
Old 02-17-2006, 10:23 PM   #7
madhavann
LQ Newbie
 
Registered: Jan 2006
Distribution: FEDORA CORE 3
Posts: 8

Original Poster
Rep: Reputation: 0
Let me try a HUB

Thanks everyone,
i will try using the hub.
madhavan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forwarding packets with Iptables DrunkenDisciple Linux - Software 2 07-24-2005 11:00 PM
Not forwarding packets meadensi Linux - Networking 0 02-08-2005 07:02 PM
Why one nic accept packets destined for second nic gibcomp Linux - Networking 2 09-09-2004 12:21 AM
Problem about forwarding packets in kernel Lite Linux - Networking 0 07-20-2004 09:33 PM
Forwarding ACK Packets snufferz Linux - Newbie 0 05-12-2004 02:10 AM


All times are GMT -5. The time now is 02:49 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration