Re: How to bypass the local routing table, to simulate a hub

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Antony,


I have not completely read / understood your situation, so forgive me for jumping in.

I don't know much about tap0 device so maybe you can eligthen me. But from what I can see you can setup a NETWORK on a tapX interface and the kernel will route all traffic to the interface as-if its a hardware device, except its not, its a software device that passes packets between userspace and the kernel interface through the use of a file descriptor / socket, created by opening a device like file.

I use the word NETWORK since it behaves like a normal interface, that is you give it an IP address that represents the kernels interface facing the userspace software/virtual network. Therefore you should have setup the interface with a netmask to allow other IPs to exist on that network, it is those IPs that your application program should assume and use.

To do this means the tap0 interface is configured along the lines of 192.168.1.8/30, using a netmask of 255.255.255.252, using 192.168.1.9 as the kernel interface IP, 192.168.1.10 as your applications IP. Then run your "ping -I tap0" again.


Now if on the other hand you are wanting to sniff all traffic to a particular IP address from your ethernet segment, but not have the kernel stack treat the packets as local, then down all the tapX interfaces, then checkout AF_RAW, NETLINK, whatever the current scheme is for injecting / sniffing packets and setup a proxy ARP addresses of the IPs you want to assume on the LAN. However if the box this is all hosted on has a lot of other traffic destined for the kernel stack you will have to receive, filter, discard all those packets through into userspace. Maybe socket filters can help in the kernel, but the point is the tapX interfaces when used as a NETWORK would be a better solution.


Darryl



Antony Lesuisse wrote:

Imagine, on a linux box, having 3 different network interfaces on the
same switch.  It is for simulating a network, using virtual tun/tap
interface:


----------------+-----+------------------------ Hub simulator|Linux| Userspaces apps | | ?--|-----|--- tap0 192.168.1.1 ? | | /dev/net/tun ?--|-----|--- tap1 192.168.1.2 ? | | ?--|-----|--- tap2 192.168.1.3 | | ----------------+-----+-----------------------



_______________________________________________
LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux