26-11-2010, 03:29 AM
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
And enter the following, changing to suit your needs
2) You will also need to make sure you set a nameserver in /etc/resolv.conf
Setting a DHCP IP
DHCP, Dynamic host configuration protocol, (automatically assigned)
1) This is how to set your interfaces to DHCP.
Enter the following
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.*
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.*