simple sample for block IP

Dear all,

I need simple code in to block certain IP from attack or use my resource web, database my network.
In addition, send him  a message that he is block or he is hacker.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abdallah1973Author Commented:
This sample is good for if i have a web site.
but I have a list of IP I need to bock through an EXE application that will always block any IP that in the list
The same idea for that one but in application
1. I have the list of IP that I need to block.
2. Block the IP and if the port is open to close.
in simple way use
I presume you already have code in place to detect these? If so, all you need to do is store the IP addresses and check them on page requests. If matches, Redirect to "banned.html" page. You can use the Cache() object to store the IPs and flush them to a database if you wish to keep them pernamently.
abdallah1973Author Commented:
if found this code in old vb6 code
private Declare Function AllocateAndGetTcpExTableFromStack Lib "iphlpapi.dll" (pTcpTableEx As Any, ByVal bOrder As Long, ByVal heap As Long, ByVal zero As Long, ByVal flags As Long) As Long
Private Declare Function SetTcpEntry Lib "iphlpapi.dll" (pTcpTableEx As MIB_TCPROW) As Long

 For t = 0 To frmFirewall.lstBlock.ListCount - 1
                        If UCase(frmFirewall.lstBlock.List(t)) = UCase(tempName) Then
                            TerminateThisConnection nLocalAddr, nLocalPort, nRemoteAddr, nRemotePort
                            Exit For
                        End If
                    Next t

Public Sub TerminateThisConnection(xLocalAddr As Long, xLocalPort As Long, xRemoteAddr As Long, xRemotePort As Long)
    udtRow.dwLocalAddr = xLocalAddr
    udtRow.dwLocalPort = xLocalPort
    udtRow.dwRemoteAddr = xRemoteAddr
    udtRow.dwRemotePort = xRemotePort
    udtRow.dwState = 12
    SetTcpEntry udtRow
End Sub

maybe will help us but not work in
abdallah1973Author Commented:
not met what I need
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.