views:

86

answers:

3

Hello, I want to stop someone with a certain MAC address from accessing a certain port on my server, I'm using this as a sort of hardware ban for a private server a friend of mine runs.

I am looking to do this in C++, and would like to know what I would need to research in order to do it. The server runs Windows.

Also, how would I find out the MAC address of the person accessing? Thankyou.

+6  A: 

Application-level sockets do not allow for MAC filtering. The only way to get the MAC is to have direct access to the TCP/IP headers themselves, which sockets do not provide access to. Unless you use a low-level intercept driver, like WinPCap, then you are just better off putting the server behind a real hardware firewall/router and let it do the MAC filtering for you.

Remy Lebeau - TeamB
+3  A: 

While I can't answer your question, MAC addresses now tend to be set in software, so can be changed pretty easily.

DrDipshit
+1. MAC address filtering provides no security because they're too easily spoofed.
Duracell
+7  A: 

Filtering on MAC addresses is only useful if the server and client are on the same LAN. The server will see the MAC address of the nearest upstream router, not the client's MAC address.

Jim Lewis
This is true. TCP does not send through the originating MAC address since they're used only for local LANs. The minute your friend's TCP packet is found to need to leave his local LAN, it will be repackaged into a _different_ ethernet packet with the router information, not your friend's information. If the friend truly has a private _server_, the IP address (or DNS name) should be consistent and you can filter on that.
paxdiablo
@paxdiablo I think the server is the one trying to ban, not being banned.
Pedro d'Aquino