Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to captuare an IP packet, change its content and resend it on Linux?

Tags:

linux

ip

packet

My question is:

How to captuare an incoming IP packet from a network interface, change its content and resend it from another network interface?

like image 539
Amir Saniyan Avatar asked Apr 03 '12 10:04

Amir Saniyan


People also ask

What must happen to an IP packet before it can be sent over Ethernet?

What is done to an IP packet before it is transmitted over the physical medium? It is tagged with information guaranteeing reliable delivery. It is segmented into smaller individual pieces. It is encapsulated into a TCP segment.

What is the difference between an IP address and an IP packet?

An IP address is the location of a resource. For example a sending or receiving computer would have an IP address, which lets other computers know where this computer is located. An IP packet contains some information, which allows these different machines to send data to each other.

What are the three parts of an IP packet?

A network packet is divided into three parts; the header, payload, and trailer, each containing values that are characteristic of it.

Is IP packet must contain?

Each IP packet contains both a header (20 or 24 bytes long) and data (variable length). The header includes the IP addresses of the source and destination, plus other fields that help to route the packet. The data is the actual content, such as a string of letters or part of a webpage.


1 Answers

The choice is yours, there is no preference (and hence no "normal").

  • using libnetfilter_queue to deliver to userspace and do extensive modification there.
  • or an xtables module, also works (since it's called by NF anyway). Allows for sufficient fine-grained configuration with help from userspace.
  • nfhook module, if you must. All configuration you must implement yourself.
  • well and finally, if you like things that hurt, you might as well implement your own virtual NIC driver.
like image 159
jørgensen Avatar answered Sep 30 '22 14:09

jørgensen