By default Raspbian is set up for DHCP which is quite fine in many cases, but less fine if you want to use it as a server or other applications where a known static IP address is important. One option is to use a DHCP reservation on a DHCP server, but if you do not have one or want to use one, you could just setup a static address in the configuration files in Raspbian
To view the current IP address use the ifconfig command.
pi@raspberrypi ~ $ ifconfig eth0 Link encap:Ethernet HWaddr b8:27:eb:9c:62:17 inet addr:192.168.10.157 Bcast:192.168.10.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1543 errors:0 dropped:0 overruns:0 frame:0 TX packets:1079 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:116617 (113.8 KiB) TX bytes:125062 (122.1 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) pi@raspberrypi ~ $
The configuration is stored in /etc/network/interfaces which can be opened with a text editor
sudo nano /etc/network/interfaces
My Raspberry Pi only have one interface, so it is the eth0 interface. By default, it is setup for DHCP.
iface eth0 inet dhcp
To configure a static IPv4 address up changed the above line to the following. Replace the addresses with those that needed in your network
iface eth0 inet static address 192.168.10.11 netmask 255.255.255.0 gateway 192.168.10.1
DNS servers are configured in the file /etc/resolv.conf. If the PI has received a DHCP assigned address, the DNS servers that the DHCP server provides, remains in the file even when the configuration is changed to static.
These are TDC DNS servers.
nameserver 22.214.171.124 nameserver 126.96.36.199