Fast guide on how to manually configure your network under linux console

Let’s say your network settings are as following:

IP: 10.10.0.25
NETMASK: 255.255.255.0
GATEWAY: 10.10.0.1
DNS SERVERS: 10.10.0.2, 10.10.0.3

Before starting it is very useful to run ifconfig, in order to see the network interfaces.

The output should look similar to this:
eth0 Link encap:Ethernet HWaddr 00:1a:31:a2:1d:de
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:251 Base address:0x6000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3153 errors:0 dropped:0 overruns:0 frame:0
TX packets:3153 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:375999 (375.9 KB) TX bytes:375999 (375.9 KB)

So, let’s setup our network adapter:

root@localhost$ ifconfig eth0 10.10.0.25 netmask 255.255.255.0 broadcast 10.10.0.255

Next you must set the gateway. We will use the route command.

root@localhost$ route add default gw 10.10.0.1 dev eth0

The above line tells the kernel that the default route is 10.10.0.1 through ethernet adapter eth0. This is very usefull especially if you have more interfaces in your system.

Everything is ok by now, except the dns resolving. For that you have to edit /etc/resolv.conf file, and add the next lines:

root@localhost$ nano -w /etc/resolv.conf
nameserver 10.10.0.2
nameserver 10.10.0.3

This is a fast way to setup your network. However this are not permanent settings, so when you will restart your system all the changes will be lost. For your settings to be permanent you have to learn about your system configuration files and modify them properly.

VN:F [1.9.11_1134]
Rating: 9.8/10 (6 votes cast)
Fast guide on how to manually configure your network under linux console, 9.8 out of 10 based on 6 ratings

About Armino

This website is about me, my experiences, my hobbies and my friends. If you are interested in my professional profile you can check it on LinkedIn.