Linux can support multiple network devices. The device names are numbered and begin at zero and count upwards. For example, a computer running two ethernet cards will have two devices labeled /dev/eth0 and /dev/eth1. Linux network configuration, management, monitoring and system tools are covered below.
The basic command in linux to manage network devices is 'ifconfig'.
This allow to edit IP, Netmask, MAC Address, and much other of an interface.
In this tutorial we try to configure ethernet adapter and start to navigate.
Typical output of ifconfig is similar of this:
[root@st4ck root]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:AA:BB:CC:DD:EE
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING 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:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:9 Base address:0x6000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:10226970 errors:0 dropped:0 overruns:0 frame:0
TX packets:10226970 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1385547296 (1.2 GiB) TX bytes:1385547296 (1.2 GiB)
|
In some case you haven't 'eth0' in 'ifconfig' list, because the interface is down and unconfigured.
To set IP address and Netmask you can do this command:
[root@st4ck root]# ifconfig eth0 192.168.0.2 netmask 255.255.255.0
|
You probably don't receive any output, you can see changes ever with 'ifconfig' command.
The next step is add default route to the route table. You can do this with 'route' command. Unconfigured output of this command is similar of this:
[root@st4ck root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.2 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
|
You can set default route with this:
[root@st4ck root]# route add default 192.168.0.1
|
In teory we are ready to navigate, but you can't resolve 'domains' without a DNS. DNS list is in the file '/etc/resolv.conf' (might not exist). You can simply set a DNS with this command:
[root@st4ck root]# echo "nameserver 212.216.112.22" > /etc/resolv.conf
|