Thursday, March 26, 2015

Setup DHCP or static IP address from command line in Linux

Read full details here: Setup DHCP or static IP address from command line in Linux


Did you ever had trouble with Network Manager and felt that you need to try to setup DHCP or static IP address from command Line in Linux? I once accidentally removed Gnome (my bad, wasn't paying attention and did an apt-get autoremove -y .. how bad is that.. ) So I was stuck, I couldn't connect to Internet to reinstall my Gnome Network Manager because I'm in TEXT mode network-manager was broken.  I learned a good lesson. you need internet for almost anything these days unless you've memorized all those manual command.


This guide will guide you on how to setup DHCP or static IP address from command Line in Linux. It saved me when I was in trouble, hopefully you will find it useful as well. In case you've only got Wireless, you can use this guide to connect to WiFi network from command line in Linux.
Note that my network interface is eth0 for this whole guide. Change eth0 to match your network interface.
Static assignment of IP addresses is typically used to eliminate the network traffic associated with DHCP/DNS and to lock an element in the address space to provide a consistent IP target.

Step 1 : STOP and START Networking service

Some people would argue restart would work, but I prefer STOP-START to do a complete rehash. Also if it's not working already, why bother?
# /etc/init.d/networking stop
 [ ok ] Deconfiguring network interfaces...done.
 # /etc/init.d/networking start
 [ ok ] Configuring network interfaces...done.

Step 2 : STOP and START Network-Manage



Read the rest of it here: Setup DHCP or static IP address from command line in Linux

No comments:

Post a Comment