how to manually configure IP address using command line in debian lenny

I know most of the guys have very well idea how to do this thing but many would be looking for this piece of information on internet and it is available too but I just like to give you few short steps and you are ready to go with your Debian system. Most of the writer just give the IP address configuration but no one share this secret that you have to enter something in resolv.conf file. Lets configure an Ethernet card on Debian manually and use the internet on command line.

Configure the Network Manually

You can use ifconfig command to configure IP address and other information and you can also enter all this configuration in a file given at the location specified below;

/etc/network/interfaces

Save Network Settings to a Configuration File

To change the current network configuration setting you’ll need to edit /etc/network/interfaces file using a text editor such as vi. This is the only way to save device setting to a configuration file so that system can remember changes after a reboot.

Open /etc/network/interfaces file as the root user:
# vi /etc/network/interfaces
Let us assign static public routable (or private) IP address to eth0, enter:

auto eth0
iface eth0 inet static
address 10.20.50.12
gateway 10.20.50.1
netmask 255.255.255.0
network 10.20.50.0
braodcast 10.20.50.255

Task: Configure a Device Dynamically with DHCP

Open /etc/network/interfaces file as the root user:
# vi /etc/network/interfaces
Let us configure eth0 using DHCP. When the device is configured by using DHCP, you don’t need to set any options for the network address configuration in the file.
auto eth0
iface eth0 inet dhcp

Save and close the file.

Start and Stop Configured Interfaces

To apply changes to a configuration file, you need to stop and restart the corresponding interface
# /etc/init.d/networking stop
# /etc/init.d/networking start
# /etc/init.d/networking restart

You can also use following command to bring down or up the eth0. Disables the device eth0, enter:
# ifdown eth0
Enables eth0 again, enter:
# ifup eth0

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.