How to change IP Address using the command line

There is a myth in the tech world that the Linux OS is some rocket science and it is impossible for beginners to adopt from Windows OS to Linux. The graphic user interface is user-friendly which gives the slight advantage of simplicity over the Linux interface. The little things that you find pretty easy in graphic user interface might be a little different in the Linux. But do you know that few commands are also available in Linux that can let you work around Linux smoothly? Let us check the process to change the network card IP address in Linux. This command is tested for all the Debian-based distributions including the Ubuntu.

  1. Open the terminal using “ALT + CTRL + T”.
  2. Type ifconfig in the terminal. This command will locate all the network interface, So, you can choose the node of which you want to change the IP address.
  3. After locating the interface, again run the ifconfig command with extra parameters that will help you change the settings of the network interface. For example, if you want to change the IP address of node eth1 jus type this command with the subnet mask.sudo ifconfig eth1 192.168.0.1 net mask 255.255.255.0 and press Enter
  4. This is just the sample command and you can choose any value that you like. To see the changes, you can type ifconfig again and you will see that the eth1 has now adopted the new IP address.
  5. Just like the IP address default gateway of the router can also be changed using the command line. Gateway of the router is changed by using the route command. Let’s take the node eth0 and to execute the following command. sudo route add default gateway 192.168.0.253
  6. If you want to confirm that the execution was successful and there was no error just type the following command and the result will be displayed on the screen. route -n

So, by using these simple commands you can change the IP address as well as the default gateway of the network card in Linux. Linux commands are not limited to just changing the IP address or small things like that, but you can execute the complex programs as well if you have the right knowledge. The only thing you need to be careful while executing the commands is that Linux commands are case sensitive. So, you need to enter the exact spellings to execute the commands perfectly.