How to Switch From Dynamic to Static IP Address (inet Addr) in Debian

Dynamic IP addresses are set as default in a fresh Debian installation. However, you can change Dynamic IP address to Static IP address as Dynamic IP might create some problems regarding internet connections or even for LAN or FTP, as did for my case. The main thing is I changed my Dynamic IP address to Static IP address and now I’ve no such problems that previously bugged me for nothing. You can do the same. Just follow the steps below:

  • Open Terminal and execute the following command:

sudo gedit /etc/network/interfaces

Here you can replace gedit with other text editor of your preference.

  • Comment out (simply put a # in front of the line) the following lines from the opened config file as I did:
#allow-hotplug eth0
#iface eth0 inet dhcp
  • Now add the following in that file following this format:
iface eth0 inet static
    address local address
    netmask subnet mask
    network network address, usually the lowest address on your subnet
    gateway gateway's IP address, usually the one greater than lowest address on your subnet
    broadcast network broadcast address, usually the highest address on your subnet
    dns-nameservers server1 server2
    dns-search defaultdomain
  • In my case I did the following:
iface eth0 inet static
    address 10.220.62.20
    netmask 255.0.0.0
    network 10.220.62.0
    gateway 10.220.62.1
    broadcast 10.220.62.255
    dns-nameservers 123.49.34.6

See, here I’ve avoided dns-search. You can do the same, it won’t effect.

  • After you’re done, Save the file and Close it.
  • Now execute the following in Terminal to restart the Network Daemon:

sudo /etc/init.d/networking restart

  • Even a restart of your PC might be a good idea. So, do it.

You’re done! Hooray!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s