• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting a static or DHCP IP in Linux
#1
Setting a static or DHCP IP in Linux

This is a tutorial on how to set either a static or DHCP IP address in Linux. This is useful for Linux servers in your LAN.

We'll be working with the /etc/network/interfaces file


Steps

Setting a static IP

1) To set a static IP

Code:
nano /etc/network/interfaces

And enter the following, changing to suit your needs

Code:
auto eth0
iface eth0 inet static
address 192.168.2.100
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1

2) You will also need to make sure you set a nameserver in /etc/resolv.conf

Code:
nano /etc/resolv.conf

Code:
nameserver 192.168.2.1



Setting a DHCP IP

DHCP, Dynamic host configuration protocol, (automatically assigned)


1) This is how to set your interfaces to DHCP.

Code:
nano /etc/network/interfaces

Enter the following

Code:
auto eth0
iface eth0 inet dhcp


Remember to change the settings to suit you, a lot of yous wont be on a *.2 network like i am, you'll probably be 192.168.1.*

  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting DNS in Ubuntu Pack3t SynAck3r 8 25,790 30-08-2011, 10:42 PM
Last Post: pat778mal
  Pulling / setting up a Microsoft Exchange account into Mozilla Thunderbird ? Mark 0 4,940 26-08-2011, 02:30 PM
Last Post: Mark

Forum Jump: