Sunday, April 20, 2008

Basic Linux IP Networking Command 1

Ifconfig - configures interface devices for use. It provides each device with its (IP) address, netmask, and broadcast address.

usage : ifconfig ${DEVICE} ${IPADDR} netmask ${NMASK} broadcast ${BCAST}

example : ifconfig eth0 netmask broadcast

eth0  Link encap:Ethernet  HWaddr 00:C1:4E:7D:9E:25
      inet addr:  Bcast:  Mask:
      RX packets:389016 errors:16534 dropped:0 overruns:0 rame:24522
      TX packets:400845 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:100
      Interrupt:11 Base address:0xcc00

You  may also use this command as :

ifconfig -a - view all the interfaces either active or inactive.
ifconfig eth0 down - shut down eth0
ifconfig eth1 up - activate eth1
ifconfig eth0 arp - enable ARP on eth0
ifconfig eth0 -arp - disable ARP on eth0
ifconfig eth0 netmask - set the eth0 netmask
ifconfig lo mtu 2000 - set the loopback maximum transfer unit
ifconfig eth1 - set the eth1 IP address


route - adds predefined routes for interface devices to the Forwarding Information Base (FIB).

usage : route add -net ${NETWORK} netmask ${NMASK} dev ${DEVICE}

example : route add -net netmask dev eth1

usage : route add -host ${IPADDR} ${DEVICE}

example : route add -host eth2

This displays the Kernel IP routing table by using "route -n" :

Kernel IP routing table
Destination   Gateway     Genmask         Flags Metric Ref Use Iface    *  UH    0      0     0 eth0    *    U     0      0     0 eth0     *        U     0      0     0 lo
default         UG    0      0     0 eth0

You may also use this command to change your default gateway :

usage : route add default gw ${IPADDR}

example : route add default gw

No comments: