etherheader points to the header of ether packet as its name implies:
printf("Source MAC address: "
"%02x:%02x:%02x:%02x:%02x:%02x\n",
etherheader[0],etherheader[1],etherheader[2],
etherheader[3],etherheader[4],etherheader[5]);
struct ether_header {
u_int8_t ether_dhost[6];
u_int8_t ether_shost[6];
u_int16_t ether_type;
}
It turns out the above code always prints:
Source MAC address: 40:40:8d:40:b8:f4
What’s wrong?
UPDATE
Destination MAC address: 40:40:8d:40:b8:f4
Source MAC address: 88:43:e1:7c:46:7f
Source host 123.126.50.73
Dest host *.*.27.*
----------
Destination MAC address: 40:40:8d:40:b8:f4
Source MAC address: 88:43:e1:7c:46:7f
Source host 114.62.80.83
Dest host *.*.27.*
Ethernet is a protocol (suite) for Local Area Networks. If your machine is statically connected, point-to-point, to a single router/switch which provides it with internet access, then this is where all your incoming packets originate from (the last hop, for your ingress traffic). This means that regardless what IP on the internet you’re trying to establish IP communication with, all packets will traverse the link between your machine and your router/switch (through Ethernet).
If you are connected to a single network element, and neither your nor its network configuration changes, MAC addresses for those two machines (network cards, to be more precise) will remain the same. This behaviour seems to be what you’re observing.