Category: tcpip

How to statically set your IP address

I just setup another server running on VirtualBox, this time I used Ubuntu Server 10.04 LTS, following how to set up a static IP address.

First of all we have to identify the network interface. A simple

$ ifconfig

will show all the interfaces available, most of the time our interface will be eth0.

In case of problems

$ cat /var/log/dmesg | grep eth

should show any potential reason.

Edit /etc/network/interfaces

$ sudo nano /etc/network/interfaces

We should have something like

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

Change dhcp to static and add the following lines adjusting the addresses to fit your network settings:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1

Restart the networking

$ sudo /etc/init.d/networking restart
* Reconfiguring network interfaces...
ssh stop/waiting
ssh start/running, process 2026

Check if effectively we own the desired IP

$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:a8:ce:d1
     inet addr:192.168.0.100 Bcast:192.168.2.255 Mask:255.255.255.0
     inet6 addr: fe80::a00:27ff:fea8:ced1/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
     RX packets:429144 errors:0 dropped:0 overruns:0 frame:0
     TX packets:1848 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:36616023 (36.6 MB) TX bytes:639911 (639.9 KB)

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:24 errors:0 dropped:0 overruns:0 frame:0
     TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:0
     RX bytes:1974 (1.9 KB) TX bytes:1974 (1.9 KB)

We can see the new IP address has been applied for interface eth0.

To check the gateway

$ route -n
Kernel IP routing table
Destination     Gateway          Genmask          Flags Metric Ref Use Iface
192.168.0.0     0.0.0.0          255.255.255.0    U     0      0   0   eth0
0.0.0.0         192.168.0.1      0.0.0.0          UG    100    0   0   eth0

192.168.0.1 is the gateway IP address for interface eth0. The flag U indicates that route is up and G indicates that it is a gateway.

How to discover all IP hosts on the local network

Sometimes I need to know which IP a machine has obtained, typical example is when I need to reach a precise machine, without the monitor, through VNC or NX. To find all the devices connected on our local network I use successfully arp-scan.

Arp-scan is developed by NTA Monitor, here is their page to this project provided open source.

Install it as usual:

$ sudo apt-get install arp-scan

Typical usage:

$ sudo arp-scan -I eth0 -l

where eth0 is the ethernet interface from which we would start the scan. To know the interfaces available on your machine:

$ ifconfig

Once the command is issued, arp-scan will look up the vendor OUI (Organizationally Unique Identifier) for every mac address found. We can do that also manually going here. Arp-scan produces a list like this:

Interface: eth0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.6 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.2.2      00:08:7b:08:02:5f    RTX Telecom A/S
192.168.2.3      00:11:5f:05:a3:f7    Intellix Co., Ltd.
192.168.2.4      00:04:ac:9e:65:4c    IBM CORP.
192.168.2.7      00:50:56:40:08:83    VMWare, Inc.
192.168.2.8      00:50:56:4a:cb:19    VMWare, Inc.
192.168.2.10     00:19:32:00:11:1d    Gude Analog- und Digialsysteme GmbH
192.168.2.11     00:0d:5d:03:5a:ef    Raritan Computer, Inc
192.168.2.12     00:1e:c1:05:28:e0    (Unknown)
192.168.2.14     00:90:fb:15:74:e0    PORTWELL, INC.
192.168.2.15     00:50:56:a7:38:31    VMWare, Inc.
192.168.2.16     00:0c:29:4b:e6:76    VMware, Inc.
192.168.2.17     00:0c:29:b2:be:37    VMware, Inc.
     .
     .
     .
192.168.2.246    00:01:e6:6e:bf:1f    Hewlett-Packard Company
192.168.2.247    00:00:48:1f:df:94    SEIKO EPSON CORPORATION
192.168.2.248    00:01:e6:24:a1:46    Hewlett-Packard Company
192.168.2.249    00:00:48:40:09:55    SEIKO EPSON CORPORATION
192.168.2.250    00:15:99:78:de:67    Samsung Electronics Co., LTD
192.168.2.251    00:10:83:a0:03:69    HEWLETT-PACKARD COMPANY
192.168.2.252    00:15:99:65:82:fe    Samsung Electronics Co., LTD
192.168.2.253    00:12:79:83:f6:b0    Hewlett Packard
192.168.2.254    68:b5:99:ac:a0:0d    (Unknown)
192.168.2.101    00:19:99:34:cb:3c    Fujitsu Siemens Computers
192.168.2.124    00:11:5b:a5:cb:d0    Elitegroup Computer System Co. (ECS)
192.168.2.0      00:1e:c1:1a:7a:a0    (Unknown) (DUP: 1)
139 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.6: 256 hosts scanned in 1.222 seconds (209.49 hosts/sec). 139 responded

WordPress Themes