Tuesday, January 18, 2011

Remotely Enable Remote Desktop on Windows Server 2003

With Remote Desktop on Windows XP Professional or Windows Server 2003 (in Windows 2000 Advanced Server, this feature was called Terminal Services in Remote Administration Mode), you can have access to a Windows session that is running on your computer when you are at another computer.

What you need to do is create the new RDP listening port via the registry:

  1. Run REGEDIT on your XP workstation or on your Windows 2000/2003 Server.
  2. Click on File, then choose "Connect Network Registry".


In the Select Computer search box either browse Active Directory to locate the remote server, or type its name in the dialog box.



Click Ok.

  1. In the remote machine's registry browse to the following key:
HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server

Under the Terminal Server key find the value named fDenyTSConnections (REG_DWORD). Change the value data from 1 (Remote Desktop disabled) to 0 (Remote Desktop enabled).

Click Ok.
  1. Close Regedit.
  2. Reboot the remote machine for the change to take effect. You can easily do so by opening a command prompt and typing the following command:

shutdown -m \\srv1 -r

After the remote machine reboots, Remote Desktop will be enabled on it. To test this from your workstation, open Start -> All Programs -> Accessories -> Communications -> Remote Desktop Connection. You can also type mstsc in the Run command.


Enter the name of the remote server in the Remote Desktop Connection logon box, supply your administrator password when prompted, and press Enter or click Ok.

Thursday, January 13, 2011

How to find IP addresses and subnet number

When you know IP address and mask number, you sometimes want to know subnet number, subnet broadcast address and range of valid IP addresses. In common ways, you can find these by convert the IP address with mask number to binary and perform boolean AND but that takes too much time. So let see how to find these answers in a short time.

Before I start, let see the general table which will used to describe IP address. In each column will be the IP address that separate by octet, dot-notation (x.x.x.x). In each row is the IP address.

Generic Subnet Table

Octet 1 2 3 4
Address



Subnet number



First Address



Broadcast Address



Last Address



Let’s start

I divide into 2 categories which depend on subnet mask:

  1. Do Maths with easy masks
    For the masks that contain only 255s and 0s. There are three masks which are 255.0.0.0, 255.255.0.0 and 255.255.255.0.
    I guess many people know this already, but l will explain a little bit to revise for someone.
    1. Find the subnet number
      • Copy first octet (mask 255.0.0.0), first two octets (mask 255.255.0.0) or first three octets (mask 255.255.255.0) from IP address
      • Put 0s in the remaining octets
    2. Find the broadcast the address
      • Copy first octet (mask 255.0.0.0), first two octets (mask 255.255.0.0) or first three octets (mask 255.255.255.0) from IP address. This is the same in ‘Find the subnet number’, step 1
      • Put 255s in the remaining octets
    3. Find range of valid IP addresses
      • To find the first valid IP address, copy the subnet number and add 1 to the fourth octet
      • To find the last valid IP address, copy the broadcast address and subtract 1 to the fourth octet
    4. Example
      • Mask 255.0.0.0
        Octet 1 2 3 4
        Address 10 110 140 1
        Subnet number 10 0 0 0
        First Address 10 0 0 1
        Broadcast Address 10 255 255 255
        Last Address 10 255 255 254
      • Mask 255.255.0.0
        Octet 1 2 3 4
        Address 10 110 140 1
        Subnet number 10 110 0 0
        First Address 10 110 0 1
        Broadcast Address 10 110 255 255
        Last Address 10 110 255 254
      • Mask 255.255.255.0
        Octet 1 2 3 4
        Address 10 110 140 1
        Subnet number 10 110 140 0
        First Address 10 110 140 1
        Broadcast Address 10 110 140 255
        Last Address 10 110 140 254
  2. Do Maths with difficult masks
    In this case, mostpeople find it’s difficult to calculate and some has to do by binary math which is time consuming. Let see the way to figure out in few seconds.
    1. Find the subnet number
      • I will define the column that contain the difficult number(not 255s and 0s) as the interesting column. For any octets fully to the left of the interesting column, copy value(s) from the original IP Address into all addresses(subnet number, first-last address and broadcast address).
        Octet 1 2 3 4
        Address 130 4 102 1
        Mask 255 255 252 0
        Subnet number 130 4

        First Address 130 4

        Broadcast Address 130 4

        Last Address 130 4

      • For any octets fully to the right of the interesting column, put 0s in the subnet number.
        Octet 1 2 3 4
        Address 130 4 102 1
        Mask 255 255 252 0
        Subnet number 130 4
        0
        First Address 130 4

        Broadcast Address 130 4

        Last Address 130 4

      • Now the tricky part, find a ‘magic number’ which is 256 minus mask’s interesting octet. In this example, it is 256 – 252 = 4.
      • Find the multiple of the magic number that is closest to, but not greater than the the interesting octet of original IP address. For this case, it is 100 (4*25) which also not greater than 102.
      • Put the result from previous step in subnet number of the interesting column.
        Octet 1 2 3 4
        Address 130 4 102 1
        Mask 255 255 252 0
        Subnet number 130 4 100 0
        First Address 130 4

        Broadcast Address 130 4

        Last Address 130 4

    2. Find the broadcast address
      • For any octets fully to the right of the interesting column, put 255s in the broadcast address. The left part should be filled already in Find subnet number, the upper.
      • Again, use the magic number. By adding the magic number to the interesting octet of subnet number and subtract 1. In this example, the magic number is 256 – 252 = 4, 100 + 4 – 1 = 103.
      • Put the result from previous step in broadcast number of the interesting column.
        Octet 1 2 3 4
        Address 130 4 102 1
        Mask 255 255 252 0
        Subnet number 130 4 100 0
        First Address 130 4

        Broadcast Address 130 4 103 255
        Last Address 130 4

    3. Find range of valid IP addresses
      The way used to find the first and last IP addresses are the same in easy mask.
      • To find the first valid IP address, copy the subnet number and add 1 to the fourth octet
      • To find the last valid IP address, copy the broadcast address and subtract 1 to the fourth octet
        Octet 1 2 3 4
        Address 130 4 102 1
        Mask 255 255 252 0
        Subnet number 130 4 100 0
        First Address 130 4 100 1
        Broadcast Address 130 4 103 255
        Last Address 130 4 103 254

How to Silently Install Dot Net Framework 2.0 Using Batch File

Introduction


When you develop an application using Microsoft Visual Studio, it always requires Microsoft .NET Framework to be installed on clients in order to run the application but the required version may be vary depends on applications. Even third-party software around the world today are sometimes require Microsoft .NET Framework so you should install .NET Framework on clients at the first time you prepare them. But generally, there are computers which actively using by users and don’t have .NET Framework. Therefore, you should find a solution to install .NET Framework on clients without interrupt them. There are many solutions to solve the problem. In this post, I show how to silently install .NET Framework 2.0 SP1 on a local computer. The minimum recommend version is 2.0 Service Pack 1. Currently, the most updated version is 3.5 Service Pack 1.

Silently installation means that the software is installed in background so it doesn’t require any user interaction while it’s installing. It is a useful method for deploy software to clients without interrupt users.

First of all, you have to download .NET 2.0 SP1 from Microsoft. Then, I’ll show the command use to install in silent mode. After that, I create a batch file to run the command to make the installation easier.

Note: To install .NET Framework 2.0 SP1, it requires Windows Installer 3.1 to be installed first.

Step-by-step


1. Download Microsoft .NET Framework 2.0 Service Pack 1 from Microsoft.
Microsoft .NET Framework 2.0 Service Pack 1 (x86) - 23.6 MB
Microsoft .NET Framework 2.0 Service Pack 1 (x64) - 46.9 MB
2. On a client, open command prompt by Start -> Run -> type cmd -> press Enter.
3. Use /q parameter to install .NET Framework 2.0 SP1 in silent mode. Type “C:\NetFx20SP1_x86.exe /q”.
Note: The path to file of yours may not be the same as the example.


4. You won’t notice any dialog or user input message. But you can check if there is any error on the installation in Application Event Log. This is the example of the successfully installation message.
Product: Microsoft .NET Framework 2.0 Service Pack 1 – Update ‘.NET Framework CRT’ installed successfully.
Note: There are also other messages in the event log about the installation. This is just one of them.

5. You can also observe in Add or Remove Programs if .NET Framework has been installed or not. Click Start -> Settings -> Control Panel -> Add or Remove Programs.



6. Next, to make the installation more practical. I’ll move the installation file to a shared folder on \\192.168.125.12\MISC so you don’t need to copy the installation file to a target computer every time. Then, I create a batch file to execute the installation in silent mode so you don’t have to type the command every time.
The batch file will look as similar as below:
\\192.168.125.12\MISC\NetFx20SP1_x86.exe /q

7. Now I’ve tried to install the software by execute the batch file with a normal user credential. I have observed an error message below.
Setup discover the following problem:
You must have administrative privileges to run Microsoft.NET Framework 2.0 SP1 Setup. Please contact your system administrator



8. The error message stated clearly that the current user doesn’t has privilege to install a software. To solve the problem, I use “runas” command to execute the installation as a domain administrator (virtual\administrator). Modify the batch file to be as below.
runas /user:virtual\administrator “\\192.168.125.12\MISC\NetFx20SP1_x86.exe /q”
Note: You can view the command reference by follow the link at the bottom.


9. Now try to run the batch file with a normal user credential again. It’ll ask for domain administrator’s password (the account which I’ve specified in the batch file). Type the password and press Enter.
Note: The password won’t show on the screen.


10. After a few minutes, observe the Application Event Log. You’ll see the message similar as the figure below.
Product: Microsoft .NET Framework 2.0 Service Pack 1 — Installation completed successfully.
Note: In user column, the user is virtual\administrator which isn’t the current user logon but it’s the user that I’ve specified in the batch file.







Thursday, January 6, 2011

How to clear ARP Cache in windows 7/Vista/XP/2000/Server 2003/2008

The Address Resolution Protocol (ARP) is very crucial for TCP/IP network communication. If you begin to notice network connectivity problems such as particular web pages not loading or not being able to ping certain IP addresses then clearing your ARP cache is a good place to start.The TCP/IP ARP Command component provides the functionality to add, delete, or display the IP address for Media Access Control (MAC) address translation


To flush/Delete the ARP cache in windows 7/Vista/XP/2000/Server 2003/2008 follow this procedure

Click on Start—>Run—> type the following command click ok

netsh interface ip delete arpcache

Dynamic ARP cache entries update persist for 2-20 minutes depending on the system.

Windows 2003 Server = 10 minutes

Windows 2000 professional/Server = 10 minutes

Windows XP = 2 minutes

Solaris = 5 minutes

Delete IP address using arp command

arp -d

Example

arp -d 10.1.1.2

Display arp table

arp -a

Add static entry to ARP table

arp -s

Example

arp -s 157.55.85.212 00-aa-00-62-c6-09

Tuesday, January 4, 2011

List of important port numbers

15 --- Netstat

21 --- FTP

23 --- Telnet

25 --- SMTP

42 --- WINS

53 --- DNS

67 --- Bootp

68 --- DHCP

80 --- HTTP

88 --- Kerberos

101 --- HOSTNAME

110 --- POP3

119 --- NNTP

123 --- NTP (Network time protocol)

139 --- NetBIOS

161 --- SNMP

180 --- RIS

389 --- LDAP (Lightweight Directory Access Protocol)

443 --- HTTPS (HTTP over SSL/TLS)

520 --- RIP

79 --- FINGER

37 --- Time

3389 --- Terminal services

443 --- SSL (https) (http protocol over TLS/SSL)

220 --- IMAP3

3268 --- AD Global Catalog

3269 --- AD Global Catalog over SSL

500 --- Internet Key Exchange, IKE (IPSec) (UDP 500)

Backup Types

You can choose from three different backup methods. Most backup strategies use a combination of two or three of these methods.

Full Backup:
A complete set of all files you wish to back up. Think of this as your 'reference set'. You only need perform a full backup occasionally.

Provides a complete copy of all your data; makes it easy to locate files which need restoring.

Takes a long time and the most space on backup media; redundant backups created, as most files remain static.

Incremental Backup:
A backup of those files which have changed since the last backup of any type.

Uses the lease time and space as only those files changed since the last backup are copied; lets you back up multiple versions of the same file.

Makes the job of restoring files fiddly, as you have to reinstall the last full backup first, then all subsequent incremental backups in the correct order; also makes it hard to locate a particular file in the backup set.

Differential Backup:
A backup of those files which have changes since the last full backup. Should be performed at regular intervals.

Takes up less time and space than a full backup; provides for more efficient restoration than incremental backups.

Redundant information stored, because each backup stores much of the same information plus the latest information added or created since the last full backup. Subsequent differential backups take longer and longer as more files are changed.

Monday, January 3, 2011

How to Use the Net User Command

The NET Command is used to manage network security resources as follows:

View user account password and logon requirements (also displays the machine type - NT Server or NT workstation)
NET ACCOUNTS

View password and logon requirements for the network domain.
NET ACCOUNTS /DOMAIN

Set the number of minutes a user has before being forced to log off when the account expires or valid logon hours expire
NET ACCOUNTS /FORCELOGOFF:minutes /DOMAIN

Prevent forced logoff when user accounts expire
NET ACCOUNTS /FORCELOGOFF:NO /DOMAIN

Set the minimum number of characters for a password.
NET ACCOUNTS /MINPWLEN:C /DOMAIN
The range is 0-14 characters; the default is 6 characters.

Set the maximum number of days that a password is valid.
NET ACCOUNTS /MAXPWAGE:dd /DOMAIN
The range is 1-49710; the default is 90 days.

Set passwords to never expire.
NET ACCOUNTS /MAXPWAGE:UNLIMITED /DOMAIN

Set a minimum number of days that must pass before a user can change a password (default = 0)
NET ACCOUNTS /MINPWAGE:dd /DOMAIN

Require that new passwords be different from 'x' number of previous passwords
NET ACCOUNTS /UNIQUEPW:x /DOMAIN
The range for 'x' is 1-24

Synchoronise the user accounts database (PDC and BDC)
NET ACCOUNTS /SYNC /DOMAIN

View user account details
NET USER [/DOMAIN]

Add a user account.
NET USER username {password | *} /ADD [options] [/DOMAIN]

Modify a user account.
NET USER [username [password | *] [options]] [/DOMAIN]

Delete a username
NET USER username [/DELETE] [/DOMAIN]

Generate a random password:

NET USER administrator /random

Add a Workgroup
NET GROUP groupname /ADD [/COMMENT:"text"] [/DOMAIN]

Edit a workgroup
NET GROUP [groupname [/COMMENT:"text"]] [/DOMAIN]

Delete a group
NET GROUP groupname /DELETE [/DOMAIN]

Add a user to a group
NET GROUP groupname username [...] /ADD [/DOMAIN]

Delete a user from a group
NET GROUP groupname username [...] /DELETE [/DOMAIN]

To View, Add or modify a local workgroup replace GROUP in the commands above with LOCALGROUP.