Strawberry_Monty
Posts: 33
Joined: Wed Sep 19, 2012 9:56 pm

How do I get a static IP

Thu Sep 27, 2012 3:58 am

na..

My PC's have static IP's and so must the Pi which has shipped dynamic in the config (DHCP)

need to change the config

first struggeling to get into the root - password unknown to me..

found out to change password with: sudo passwd root and entering my own password. note: some wrote that root originally had none, but it was impossible to enter no password at login.

Then tried to run MC to find/edit the config - BUT WHAAAT - MC NOT INSTALLED BY DEFAULT (see my other post about getting installed this)

Ok - into the graphical if with startx and consulting Debbian manual. The config is in in folder /etc/network and file interfaces

change
iface eth0 inet dhcp
to
iface eth0 inet static
and add below
address 192.168.1.144
netmask 255.255.255.0
gateway 192.168.1.1
dns-domain monty
dns-nameservers 8.8.8.8

needless to say that You must know what IP subnet and DNS server You are having

User avatar
MrBunsy
Posts: 185
Joined: Mon Feb 20, 2012 1:48 pm
Location: Southampton, UK
Contact: Website

Re: How do I get a static IP

Thu Sep 27, 2012 8:00 am

Have a looksee here - http://wiki.debian.org/NetworkConfigura ... e_manually

Only address, netmask and gateway are required. You also probably want to be careful to set an IP that your dhcp server won't dish out to someone else automatically (anyone know if modern ones are smart enough not to have that problem?).

A small gotcha I found is that if you move the pi between networks where the router, acting as a dns server, has a different IP you'll have to also edit /etc/resolv.conf

Alvaro
Posts: 29
Joined: Sun Aug 19, 2012 8:47 am

Re: How do I get a static IP

Thu Sep 27, 2012 3:48 pm

To view your current route/gateway, you can use


netstat –nr


Now you can edit the file using


nano /etc/network/interfaces


Look for the line called “iface eth0 inet dhcp” to “iface eth0 static” and add the info from netstat to keep the current IP, and the result could be like this, assuming your router is 192.168.1.1 and you want your static IP to be 192.168.1.10:

CODE: SELECT ALL
# The loopback interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1



When all this info is in place, press Control+x, y to save and enter to exit.

Then type


/etc/init.d/networking restart

http://forums.debian.net/viewtopic.php?f=16&t=54670

Return to “Troubleshooting”