in reply to Re: Setting MAC addresses with Net::Frame::Simple
in thread Setting MAC addresses with Net::Frame::Simple

Thanks. This example was useful but i am running into two ethernet headers issue. With that code, i can see that my client sends out the packet but it has one ethernet header (first one) that has src/dst MACs that machine inserts . After that are the src/dst mac addresses that i am inserting using the code. That is causing a bogus ip packet. Not sure if this is my client issue or code.

  • Comment on Re^2: Setting MAC addresses with Net::Frame::Simple

Replies are listed 'Best First'.
Re^3: Setting MAC addresses with Net::Frame::Simple
by beech (Parson) on Nov 19, 2016 at 20:32 UTC

    I'm sorry I'm having a hard time understanding what you're trying to say

      The code doesn't seem to be changing the MAC addresses. Even if i specify some random MAC address for source and destinations, it looks like ethernet frame is sent out with source MAC of my interface and for destination MAC it is doing arp so basically its following the ARP table instead of the input that i am providing.

      Can we upload file or paste image on perlmonks forums? It will be much easier looking at it.

      FYI..this is the code i am trying to test
      #!/usr/bin/perl use Net::Frame::Simple; use Net::Frame::Layer::IPv4; use Net::Frame::Layer::TCP; use Net::Frame::Layer::ETH; use Net::Frame::Device; use Net::Write::Layer3; use Net::Frame::Dump::Online; use Net::Write::Layer2; my $src = '1.1.1.39'; my $target = '1.1.1.99'; my $port = 22; my $eth = Net::Frame::Layer::ETH->new(src => "00:0c:29:d1:03:06", dst +=> "03:03:03:03:03:03"); my $ip4 = Net::Frame::Layer::IPv4->new(src => $src,dst => $target); my $tcp = Net::Frame::Layer::TCP->new(dst => $port, options => "\x02\x +04\x54\x0b",payload => 'test'); my $oSimple = Net::Frame::Simple->new(layers => [$eth, $ip4,$tcp], pad +ding => 'G'x2); my $oWrite = Net::Write::Layer3->new(dst => $target); $oWrite->open; $oSimple->send($oWrite);

        I believe your issue is Net::Write::Layer3 while trying to pass an Ethernet header. Try using Net::Write::Layer2 for your $oWrite object.

        The frame you're creating ($eth, $ip4, $tcp) works fine for me using Perl Packet Crafter (see Re: Net::RawIP for IPv6) on Windows 7 x64 with Strawberry 5.22.1 x64. On Windows, the Net::Write packages won't install which is why I rolled my own in the form of PPC.

        UPDATE:

        VinsWorldcom@C:\Users\VinsWorldcom> ppc -i wlan0 Welcome to Perl Packet Crafter (PPC) Version: 1.11 wlan0 ppc> $src = '1.1.1.39'; ppc> $target = '1.1.1.99'; ppc> $port = 22; ppc> $eth = Net::Frame::Layer::ETH->new(src => "00:0c:29:d1:03:06", ds +t => "03:03:03:03:03:03"); ppc> $ip4 = Net::Frame::Layer::IPv4->new(src => $src,dst => $target); ppc> $tcp = Net::Frame::Layer::TCP->new(dst => $port, options => "\x02 +\x04\x54\x0b",payload => 'test'); ppc> $oSimple = packet $eth,$ip4,$tcp; ppc> hexdump $oSimple; 0x00000: 03 03 03 03 03 03 00 0c 29 d1 03 06 08 00 45 00 ........).. +...E. 0x00010: 00 30 b5 65 00 00 80 06 80 d7 01 01 01 27 01 01 .0.e....... +..'.. 0x00020: 01 63 e8 9c 00 16 13 b4 a0 f0 00 00 00 00 60 02 .c......... +...`. 0x00030: ff ff c0 0e 00 00 02 04 54 0b 74 65 73 74 ........T.t +est ppc> print $oSimple->print; ETH: dst:03:03:03:03:03:03 src:00:0c:29:d1:03:06 type:0x0800 IPv4: version:4 hlen:5 tos:0x00 length:48 id:46437 IPv4: flags:0x00 offset:0 ttl:128 protocol:0x06 checksum:0x80d7 IPv4: src:1.1.1.39 dst:1.1.1.99 TCP: src:59548 dst:22 seq:0x13b4a0f0 ack:0x0000 TCP: off:0x06 x2:0x0 flags:0x02 win:65535 checksum:0xc00e urp:0x0 +0 TCP: optionsLength:4 options:0204540b TCP: payload:74657374 ppc> sendp $oSimple; . Sent 1 packet ppc>

        Forgot to add in my earlier comment. If i print $oSimple, it is showing the correct src and dst MACs (the ones that i am using in the code). Its the actual packet that its putting on the wire which has incorrect src and dst MACs.My client is Fedora VM.