Search code examples
linuxdebianstatic-ip-address

Assigning static ip in linux


I've tried to assign static ip to my raspberry computer, yet it doesn't assign it after rebooting. My /etc/networ/interfaces file looks like this:

auto lo

iface lo inet loopback
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
#iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

After rebooting and using ifconfig command it shows me that the address is different. What should I do to make it assign data from the file?


Solution

  • It's /etc/network/interfaces not /etc/networ/interfaces and you forgot to add:

     auto eth0
     iface eth0 inet static
    

    You should do:

     /etc/init.d/networking restart
    

    or

     ifdown eth0 
     ifup eth0
    

    Instead of rebooting, Also make sure that 192.168.1.2 isn't used already.