Jan 26, 2014

How to configure static network IP address in Linux

Sometimes in Linux we need to have a static IP address, for example to install a Hadoop cluster, this is a recommended step. Though in windows it can be done graphically, in Linux it has an interesting way to do through a few commands. Let's take a look.

Part One: configure a static IP address in a physical machine
Note: here a physical machine I mean a machine that installs Linux OS directly, rather than a virtual machine.
Also almost all operations here need a sudo access, so we can sudo to an qualified account or add sudo ahead to each of the command.
1. view or edit 70-persistent-net-rules file
open a terminal, type
cat /etc/udev/rules.d/70-persistent-net-rules



By default, the name will be eth0, which means it will use a file name "ifcfg-eth0" to control the network settings,  but you can also let it use a new control file, say for example eth1. This can be done by in terminal, type
vim /etc/udev/rules.d/70-persistent-net-rules

and modify the name value to eth1.

2. Modify a configuration file
cd /etc/sysconfig/network-scripts
ls


You will see a file named ifcfg-eth0, which is the network configuration file as we mentioned earlier.
If you step1 you configured it to use a new file for example eth1, then you need to create a new configuration file:


vim ifcfg-eth1

Please configure it like below.

Note:
1). NM_CONTROLLED must set to no, so that it's not controlled by a service called NetworkManager
2) BOOTPROTO value is static, because it's a static IP. If it's controlled by NetworkManager, the value is dhcp
3) Add the entry for GATEWAY, IPADDR, and DNS here. If you have multiple DNS, you can put DNS1=...; DNS2=...; if you have only one DNS, you just put DNS1=....
4) People might have question that how I can know what values I can input in step 3. Here are two commands that we can use: ifconfig and route

3. Add DNS IP information in /etc/resolv.conf
vim /etc/resolv.conf


4. Persistent the configuration
1) We want to stop NetworkManager, so that the IP is set as we input and will not be changed by the service.
service NetworkManager stop

2) Make service NetworkManager by default not started when reboot system
chkconfig NetworkManager off

3) If you are using a new control file, for example in step 1 you want it to use eth1, and the original one is eth0. We need to bring down eth0 and bring up eth1
ifdown eth0

ifup eth1

4) restart network service
service network restart

5) if in step 3 or 4 you met some errors for example saying eth1 cannot be initialized. please reboot the system
reboot


Now you will have a static IP successfully configured.

Part Two:  configure a static IP address in a VMware virtual machine
configure a static IP in virtual machine is similar as doing it in physical machine, but there are a few differences.
Step 1. Same as step 1 in part one
Difference: In case you run vim /etc/udev/rules.d/70-persistent-net.rules and get the result as below. You may not know which is the right one to change.

Here you need to check in VMware your virtual machine settings by
right click your virtual machine name --> Network Adapter --> Advanced
It will show the MAC address, comparing it with the result above, now you will now it's the second one to modify.

Step 2: the same as Step 2 in part one
Difference: VMware NAT settings by default use 192.168.136.2 as the DNS and GATEWAY


so your configuration setting can be like below

Step 3: the same as Step 3 in part one
Step 4: the same

OK. All set!

If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

Jan 23, 2014

[Solved]Internet Explorer prompt "Request for permission to use a key" every time

I have imported a digital key but when I apply it, internet explorer always prompt a message "Request for permission to use a key" which is very annoying.



I searched but the posts in microsoft forum didn't point me to the right direction. Finally I figured out that the reason of this problem is that when I imported this key, I selected "Enable strong private key protection..." as shown below, which is by default selected.

Now how to solve this problem becomes very simple: delete the key and re-import it with the "Enable strong private key protection" check box unchecked. 

If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

Jan 14, 2014

Compile and Run Java Program in Command Window

I cannot recall the old days when we used the command window to compile and run a Java program, because we get used to use IDE like Eclipse. But it worth to make a note here:

1. Say you have write a simple program Hello.java, which will print "Hello World", for example the program is in directory called D:\temp

public class Hello{
 public static void main(String[] args){
  System.out.println("Hello World");
 }
}


2. Launch a command window, and go to folder D:\temp
javac Hello.java 
3. Here is the important part:
java -cp . Hello

Note:
-cp is the option to specify where the class path is,
. means the current folder, you can also specify a detail folder like D:\temp


If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

Jan 6, 2014

How to install Windows 8 or Windows 8.1 from USB

DVD is decommissioning...We now watch TV series online, rather than renting from DVD stores, listen to music online, now we can even install Windows operation system online, and Microsoft develops a tool to help this.

Update: this tool is only valid for official Microsoft image file. Microsoft will do a check on whether the img file is valid. 

The name is Windows7-USB-DVD Download tool.
The introduction page is this:
http://www.microsoftstore.com/store/msusa/html/pbPage.Help_Win7_usbdvd_dwnTool
You can also download it directly:
http://images2.store.microsoft.com/prod/clustera/framework/w7udt/1.0/en-us/Windows7-USB-DVD-tool.exe


When you download an iso image, you can use this tool to make a bootable USB device in 4 steps. Plug your device in your computer, make the boot device as flash drive, and then Bing! everything flies all the way...

If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

A Great Search Tool: Everything

Good tools can make your life easier, this is the moment in my head a famous advertise quote plays in loop:
Technology improves life...

I found a tool that fits in this category, the name is
Everything

The official site is: http://www.voidtools.com/
Everything is a tool that can quick search all files in your disk. You can type the name you want to search and the tool list all the files which name contain the keyword. Three things make the tool extraordinary:
No. 1: the index file it very small
No. 2: the tool itself is small
No. 3: search result is shown immediately.

Besides, it has a zip version if you don't need to install from a installer.

For example, if I want to search search "javascript"
The result is shown immediately in the list, and we can double click to open it or right click a file and choose "Open path" to open the folder in windows explorer.

Moreover, it supports regular expression and FTP... In all, a good tool to use.

If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.