Wednesday, January 21, 2009

Create a Static IP from the Command Line

Creating a static IP from the command line is a very short task. All you need to edit is one configuration file and restart the networking service. You will need to know the settings for your network to do this. I will show how to set a static IP of on a network with a gateway of
  1. Open the configuration file in your favorite editor (mine is nano)
    sudo nano /etc/network/interfaces
  2. Comment out the section where dhcp is being used (put the # in front of the line):
    #auto eth1
    #iface eth1 inet dhcp
  3. Add a section like this example:
    auto eth1
    iface eth1 inet static
  4. Close and save the file
  5. Reload the network service:
    sudo /etc/network restart
  6. Check to make sure you can access other computers/internet by using ping:
  7. If you don't get a response then you may have set your network information incorrectly. Just go back and repeat this process at step 3.
Make sure you have entered the correct information for YOUR network. Once you have the static IP set up properly you can then have your other computers access that computer through it's IP address.

1 comment: said...

Thank you. These were the best directions I found. Very very helpful.