0

How do I change the IP address from DHCP to my static IP (reserved for this server)?

What are the exact commands to get into the configurattion interface?

2

You have two options. However, since you need to change the IP address to static, the only way is to set-up a manual/static IP editing the /etc/network/interfaces file. for that you need to edit the interfaces file with;

sudo nano /etc/network/intarfaces

You'll ideally see something like;

auto eth0
iface eth0 inet dhcp

Replace it with;

auto eth0
iface eth0 inet static
address x.x.x.x
netmask x.x.x.x
gateway x.x.x.x

Moving further, if you have or require domain to be resolved along with DNS servers, you may add few more lines to the file, similar to;

auto eth0
iface eth0 inet static
address x.x.x.x
netmask x.x.x.x
gateway x.x.x.x
dns-search example.com
dns-nameservers x.x.x.x x.x.x.x

Please note, there are two sets of x.x.x.x within the DNS name servers (Primary and Secondary) with a space. You may use one pair or both depending on your requirement.

To save the file select ctrl+o, -> enter and exit with ctrl+x.

And then just to be sure, simple restart the interface with;

sudo ifdown eth0           # wait for sometime
sudo ifup eth0             # and then issue this to restart

Also, as a final step, simply type below to confirm the interface change;

ifconfig -a

Alternative way;

Refer to your server or the device which responds to DHCP requests and add a reservation, in case if you do not like to play with the server, files.. etc.

In order to get the MAC address for reservation, simply check the interface information with a;

ifconfig eth0                 # or type ifconfig -a

which should ideally display something similar to below;

ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:15:c5:4a:16:5a  
          inet addr:10.0.0.100  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::215:c5ff:fe4a:165a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:466475604 errors:0 dropped:0 overruns:0 frame:0
          TX packets:403172654 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2574778386 (2.5 GB)  TX bytes:1618367329 (1.6 GB)
          Interrupt:16 

Where you see the HWaddr 00:15:c5:4a:16:5a and assign it to the DHCP reservation.

Hope this helps!

More: Networking Configuration Guide

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.