In this tutorial, we'll give you step by step instructions on how to change your server's IP address on Ubuntu. Remember that you need to be root user or have root privileges to perform this commands.

Now, open up the /etc/network/interfaces file. We're going to use vi, but you can choose the editor of your choice.

1. Confirm your current IP address:

 

ifconfig eth0

 

You should have an output like this:

 

eth0 	Link encap:Ethernet HWaddr 00:16:3C:2A:76:60
 	inet addr:10.10.10.39 Bcast:10.10.10.63 Mask:255.255.255.224
 	inet6 addr: fe80::216:3cff:fe2a:7660/64 Scope:Link
 	UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 	RX packets:3287516 errors:0 dropped:0 overruns:0 frame:0
 	TX packets:1961807 errors:0 dropped:0 overruns:0 carrier:0
 	collisions:0 txqueuelen:1000
 	RX bytes:1048333886 (999.7 MiB) TX bytes:2596365984 (2.4 GiB)

 

Pay special attention to the values of inet addr, Bcast and Mask. This reflects your current IP addressing.

 

2. Replace the values with the new IP address

You need to edit the eth0 interface in order to change the IP address and the corresponding networking values.

 

sudo vi /etc/network/interfaces

 

Edit the values of address, gateway, netmask

 

auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

 

Save and close the file

 

3. Restart the network service:

 

sudo /etc/init.d/networking restart

 

4. Confirm the changes:

 

ifconfig eth0

 

You should see the inet addr, Bcast and Mask values updated.

 

Thank you!

 

Test on a Miami VPS Now

or

Deploy on a Miami Dedicated Server

Was this answer helpful? 52 Users Found This Useful (322 Votes)