Block IP address with Windows Firewall 2008
This procedure helped us when someone wanted to hack our server,If you ever feel that someone may be trying to break into your server or know an IP address that you want to block from accessing your server there is a built in firewall on all of our 2008 DDS servers. You can use this firewall to block either a range of IP addresses or a single address.
- Log into your server via RDP.
- Click on start > administrative tools > windows firewall with advanced security
- On the left side of the firewall window click on the inbound rules option.
- On the right side of the screen click on New Rule.
- Click on the custom radio button and then click next.
- Make sure the All programs radio is selected then click next.
- On the protocol and ports options leave everything at its defaults and clicknext.
- On the scope screen you will see two boxes the top one is for local IP addresses and the bottom is forremote IP addresses. In this scenario we are trying to block an outside (remote) IP from accessing anything on the server so we will need to add the IP address to this section only as it will not be a local IP address.
- Click on the radio that says these IP addresses in the remote section as shown below:
10 、Click on the Add button.
11、In the next window we will be adding a single IP address to the rule, you can also add an entire range at this point if you wish.
12、Click ok, click next.
13、Make sure you select the Block the connection radio on the next screen and then clicknext.
14、Leave all of the options on the next screen checked this will be sure to block the IP no matter the connection they are trying to use. Clicknext.
15、Name the rule on the next screen something you can remember in case you wish to remove or edit it in the future. Clickfinish and thats it
//*************************************************************************************************************************************************************************************
class Program
{
static void Main(string[] args)
{
//HttpGet("http://localhost:52373/Index.aspx");
HttpPost("http://localhost:52373/Index.aspx", "username=zhangsan&pwd=123");
}
/// <summary>
/// GET请求
/// </summary>
/// <param name="URI"></param>
/// <returns></returns>
public static string HttpGet(string URI)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
//req.Proxy = new System.Net.WebProxy(ProxyString, true); //true代表没代理
System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
string responseStr = sr.ReadToEnd().Trim();
return responseStr;
}
/// <summary>
/// 发送POST请求
/// </summary>
/// <param name="URI"></param>
/// <param name="Parameters"></param>
/// <returns></returns>
public static string HttpPost(string URI, string Parameters)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
//req.Proxy = new System.Net.WebProxy(ProxyString, true);
//POST请求参数
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
//We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length); //Push it out there
os.Close();
System.Net.WebResponse resp = req.GetResponse();
if (resp == null) return null;
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}