Skip to contentSkip to conversation

Linux Routers working

DISCUSSION cranium2003 2 participants 2 messages May 13, 2005 – Jun 4, 2005 netfilter

lore
Share & tools
lore
#0 lore raw
Quoted 7 lines · --- Jonas Berlin

Quoting cranium2003 on 2005-05-13 04:15 UTC:

Quoted 1 line

Is there any way on linux routers to know

on

Quoted 1 line

which interface packet is forwarded before

actually

Quoted 1 line

packet trasmission begins?

Quoted 8 lines

In the FORWARD table you know both the incoming and outgoing interface:

This will match packets coming in from eth0 and
going out on eth1:

iptables -A FORWARD -i eth0 -o eth1 ...

Can i get that information thru' C program
user/kernel mode netfilter program? Because you have given the rule to forward packet but what if Router have 3 or 4 NIC network interfaces? I want to print somrthing like LOG that prints that packet has srcip and dstip and is going through eth0/eth1/eth2/eth3.

Quoted 4 lines
Quoted 2 lines

Also before packet
processed by IP layer can it be possible to know

from

Quoted 1 line

which adjecent Router'IP packet came to that

Quoted 8 lines

router?

No, but the MAC address is available. You just have to find out what the
mac address of the router in question and do:

iptables -A INPUT -m mac --mac-source
01:23:45:67:89:AB ...

No suppose i have no info about adjecent
routers mac addresses and when packet came at destination Router at Link layer/IP layer can i determine from which router the packet came to destination router?
regards,
cranium

Discover Yahoo!
Get on-the-go sports scores, stock quotes, news and more. Check it out!
http://discover.yahoo.com/mobile.html

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoting cranium2003 on 2005-05-13 06:09 UTC:

Quoted 7 lines
Quoted 1 line

iptables -A FORWARD -i eth0 -o eth1 ...

Can i get that information thru' C program user/kernel mode netfilter program? Because you have given the rule to forward packet but what if Router have 3 or 4 NIC network interfaces? I want to print somrthing like LOG that prints that packet has srcip and dstip and is going through eth0/eth1/eth2/eth3.

In the kernel it's surely available.. In userspace, ULOG might give the information, I'm not sure..

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

Also before packet processed by IP layer can it be possible to know from which adjecent Router'IP packet came to that router?

No, but the MAC address is available. You just have to find out what the mac address of the router in question and do:

iptables -A INPUT -m mac --mac-source 01:23:45:67:89:AB ...

No suppose i have no info about adjecent routers mac addresses and when packet came at destination Router at Link layer/IP layer can i determine from which router the packet came to destination router?

Well the mac address is the only way to tell which adjecent router the packet came from. You could use the arp table to determine the ip of that router.

- --
- - xkr47
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCoW+axyF48ZTvn+4RAq5VAKCv+U09k0cWZ1zsnvqXsGKG/T46ewCgk5bf d7dlNXN7WYET32UTyH8VVVA=
=G2Nt
-----END PGP SIGNATURE-----