Tuesday, February 26, 2013

Basic Ubuntu Networking


Step 1: Install Ubuntu

Download ubuntu LTS (long term support) version and install.

Step 2: Configure interface (LAN card) to get Internet

a. Check cable connection status:

=> mii-tool
=> ethtool eth0

b. Check interfaces:

=># ifconfig -a (for all interfaces)
=># ifconfig -a | grep eth0 (for only eth0 interface)

c. Stop/down interface eth0: (assuming your interface is eth0)

=># ifconfig eth0 down

d.1. Set IP Address Permanently

=># cd /etc/network/
=># ls
=># gedit interfaces

[ auto lo
iface lo inet loopback ]

auto eth0 (your interface_name)       
iface eth0 inet static
                        address ip_address
                        netmask your_netmask
                        network your_network_address
                        broadcast  broadcast_address [optional]
                        gateway your_gateway_address       

Type your ip address, netmask and other addresses.

Example:

iface eth0 inet static
                        address 192.168.0.10
                        netmask 255.255.255.0
                        network 192.168.0.0
                        broadcast 192.168.0.255
                        gateway 192.168.0.1             

Save & Exit
d.2. Set IP address temporarily (after reboot it will be erased automatically):

Syntax: ifconfig interface_name ip_address netmask your_netmask
e.g:
=># ifconfig eth0 192.168.0.10 netmask 255.255.255.0

e. Add static DNS server_ip

=># gedit /etc/resolv.conf

nameserver 192.168.1.1 (type your dns server’s ip)

Save & Exit

f. Up/Start interface eth0:

=># ifconfig eth0 up

g. restart interface configuration file:

=># /etc/init.d/networking restart

h. Check ip:

=># ifconfig eth0

For GUI configuration tool, type the following command at terminal:

=># network-admin &

Step 3: Troubleshoot Internet Connection

Check the followings:

            => ping host_ip
            => ping gateway_ip
            => ping dns_ip

Check dns file:

            => cat /etc/resolv.conf

From the above command you can you can easily find out the problem.

Step 4: Change Hostname

Step 1:
=> gedit /etc/hostname

type your hostname
save & exit

Step 2:
=> gedit /etc/hosts

after localhost type your hostname as
127.0.1.1         hostname

save & exit

Reboot your system to take effect.

Step 5: Common Problems and Solutions:

Destination Host Unreachable

The possible reasons for the error Destination Host Unreachable
1. The ping packet find the destination network but failed to find the destination computer in that network.
2. Packet Routing issue.
3. Destination host might be down

Solutions - Destination Host Unreachable

The possible fix for the ICMP error message "Destination Host Unreachable" are:
1. Make sure that local host is configured correctly
2. Make sure Destination Computer/Device is up
3. Disable the Firewall and check for the issue.
4. Perform a tracert to the destination IP and check where the problem present

Destination net unreachable

Reasons for the ICMP echo Destination net unreachable
1. The ping packet couldn't find the destination network
2. Packet Routing issue.
3. Destination network path might be down.

Solution - Destination net unreachable

The possible troubleshooting steps for the ICMP error message "Destination net Unreachable" are:
1. Make sure that local host is configured correctly
2. Check the default gateway
3. Disable the Firewall and check for the issue.
4. Refresh routing table information and ping again.

Step 6: Update packages

a. update command updates the list of available packages, but it install nothing. But          upgrade actually install newer versions of the packages.

=># apt-get update
=># apt-get upgrade

b. Install Flash Plugin

=># apt-get install flashplugin-nonfree

Step 6:  Control Dual Boot

=># apt-get install startupmanager
            System -> Administration -> StartUp-Manager -> choose your first boot....
Step 7: Know about the system and networking information

a. Display system information

=># uname -a
=># cat /etc/issue (for version)

b. Display the routing table

=># /sbin/route
=># /sbin/route -n

Step 10: Display current active Internet connections

=># netstat -nat

IP and Port scanning using ‘nmap (network Mapper)’ command

=># apt-get install nmap
=># nmap tcp

Display output for active/established connections only

=># netstat -e
=># netstat -te
=># netstat -tue

Display open ports
=># netstat -tulp

OR

=># netstat -tulpn

Step 11:  To see the manual of commands

=># man ifconfig
=># man netstat
=># netstat --help

9. Find out what command is used for particular task by searching the short descriptions and manual page names for the keyword.

=> man -k 'delete directory'
=> apropos -s 1 remove

Display short descriptions of a command:
=> whatis rm
=> whatis netstat