Setting a static IP address

If you’re on Linux (or any Unix variant) and want to set a static IP address for your machine, make sure the interfaces file is as below. Comment out anything that are not shown in the lines below. This is based on a 192.168.1.0 network; if your’s is 192.168.0.0, change accordingly.

(You may need to have root privilege to perform this action)

First, bring down the interface using : ifdown eth0 [or eth1 as appropriate]

The file is located at: /etc/network/interfaces
Use an in-terminal editor like nano to edit this file. You can use command below in Terminal to open/ edit this file:

Go to the directory /etc/network/

and type in: nano interfaces

after the necessary changes are made use CTRL+O to save and exit.
Next, use ifup eth0 [or eth1 as appropriate] to bring the interface back up to reflect changes.
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.0
broadcast 192.168.1.254

Leave questions and comments below.

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