Wednesday, October 04, 2006

Linux Network Basic

Display all the interfaces you have on your server:
ifconfig

Display all interfaces as well as inactive interfaces you may have:
ifconfig -a

Assign the eth0 interface the IP-address 192.168.1.100 with netmask 255.255.255.0:
ifconfig eth0 192.168.1.100 netmask 255.255.255.0

Assign the default gateway for eth0 to 192.168.1.1 (for example your router):
route add default gw 192.168.1.1 eth0

Verify that you can reach your router (192.168.1.1):
ping 192.168.1.1

Display the routing information with the command route to see if routing entry is correct:
route -n

Check the status of the interfaces quickly:
netstat -i

Show all active connections:
netstat

Show all active TCP connections:
netstat -t

DNS lookups (3 different ways) and displays the answers that are returned from the name server (To troubleshoot DNS problems):
dig ubuntulinux.org
nslookup ubuntulinux.org
host ubuntulinux.org

Determine the network route from your computer to some other computer:
traceroute www.ubuntulinux.org

View your ARP (used by a networked machine to resolve the hardware location/address of another machine on the same local network) Cache:
arp

Remove any entry from the ARP cache for the specified host (for example 192.168.1.103):
arp -d 192.168.1.103

Check traffic in network :
tcpdump -n arp

Send out unsolicited ARP messages so as to update remote arp caches (for example 192.168.1.103):
arping 192.168.1.103

Shutdown a specific interface (for example eth0):
ifconfig eth0 down

Activate a specific interfrace (for example eth0):
ifconfig eth0 up

Stop all network devices manually on your system (Debian specific):
/etc/init.d/networking stop

Start all network devices manually on your system (Debian specific):
/etc/init.d/networking start

Restart all network devices manually on your system (Debian specific):
/etc/init.d/networking restart

Networking configuration is stored in the following file:
/etc/network/interfaces

Resource:
Ubuntu Linux Blog by Ralph
http://www.linuxhelp.net/guides/networkbasics/

1 comment:

Kshitij said...

ifconfig eth0 192.168.1.100 netmask 255.255.255.0
this command is usually used with another parameter 'broadcast'. even this might be sufficient but the use that i've seen.