I've been trying to send packets to a tap interface using python. I'm monitoring the tap interface using wireshark and no packets are being received. I'm doing this as an exercise mainly to help my understanding of vpns, ethernet bridging and socket programming in python.
My System Setup is as follows:
Ubuntu Desktop 11.10 Python 2.7 eth0 ip: 192.168.1.6 tap0 ip: 10.0.0.1
I first setup the tap as follows:
sudo openvpn --mktun --dev tap0 sudo ifconfig tap0 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255 promisc up
This starts the tap0 interface and creates a kernel routing rule to 10.0.0.1/24 via tap0.
Here is the route table:
$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 * 255.255.255.0 U 0 0 0 tap0 192.168.1.6 * 255.255.255.0 U 1 0 0 eth0 default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
Next I start python interactive and create a simple UDP socket.
import socket s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) s.sendto('helloworld',('10.0.0.2',12345))
I run the sendto command with Wireshark monitoring on tap0. Now, there is no host at 10.0.0.2 on my network, but I should at least see some outgoing traffic on the tap0 interface. I have replicated this in windows and it seems to work ok.
I can only think that the problem lies somewhere in the setup of the tap0 interface under linux. That or my mediocre understanding of this stuff.