Showing posts with label networking. Show all posts
Showing posts with label networking. Show all posts

Tip: Using nmcli to connect to Internet in Enlightenment

April 03, 2015
If you are using Enlightenment in OpenSUSE or some other Linux distribution1 , chances are you may face problems in using the NetworkManager to connect to Internet.

This is because the  NetworkManager applet (nm-applet) doesn't show itself in the taskbar of the Enlightenment desktop. And as the saying goes - what you can't see, you can't control.

How to Configure a Network Interface Card in Linux

March 02, 2012
This guide explains how to configure a network interface card in Linux.

If you are using a modern Linux distribution, chances are your network card will be detected automatically and configured for DHCP.

However, there may be instances where you are forced to configure your network interface card manually. This guide explains the step by step process to configure a network interface card in Fedora Linux.

Cheat Sheet For Networking Professionals

October 21, 2009
Free download of a collection of cheet sheets for computer networking professionals. All the cheat sheets are in PDF and are beautifully made. The cheat sheets are segregated into different categories such as -
  1. Protocols (BGP,EIGRP, First Hop Redundancy, IEEE 802.11 WLAN, IEEE 802.1X, IPsec, IPv4 Multicast, IPv6, IS-IS, OSPF, Spanning Tree)
  2. Applications (tcpdump,Wireshark display filters)
  3. Reference (IOS IPv4 Access Lists, IPv4 Subnetting, Common Ports)
  4. Syntax (Markdown, MediaWiki)
  5. Technologies (Frame Mode MPLS, QoS, VLANs)
  6. Miscellaneous (Cisco IOS Versions, Physical terminations)

A new way to look at networking

May 09, 2007 0 comments
Van Jacobson is a research fellow at PARC. Prior to that, he was the Chief Scientist and co-founder of Packet Design, Chief Scientist at Cisco and has also headed the Network Research group at Lawrence Berkeley National Laboratory.

Van talks at Google Tech Talks about the concept of a network and how it enables the efficient transfer of data from one remote location to another. In the talk Van laments how the network research in the US has stuck in a dead end for the past decade or so and it should be a wonderful time for networking as every thing is connected to everything else, there are cell phones, computers, laptops, PDAs and so on and each can be connected with each other. But unfortunately as Van puts it every thing we do with networking is getting harder. Wireless barely works and information or data is not at sync with all the diverse devices we use. In his talk he puts forward his idea of how networking can be made simpler.

A very informative talk worth watching by anyone who is interested in knowing how computer networks work. Duration: 1 Hr 21 Min



Ifconfig Command - Explained in Detail

November 20, 2006 0 comments
ifconfig is a command line tool used to configure a network interface in Linux.It can be used to set-up any/all the network interfaces such as Ethernet, wireless, modem and so on that are connected to your computer.

ifconfig command provides a wealth of knowledge to any person who takes the time to look at its output. Commonly, the ifconfig command is used for the following tasks:

Configuring an interface


You can configure an Ethernet card, wireless card, loop back interface or any other network interface device with ifconfig.

As an example, if you want to set up the IP address of your Ethernet card, you can pass the necessary options to the ifconfig command as follows:

# ifconfig p2p1 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255 up

Where the 192.168.0.1 number pertains to the IP address of your machine. I have used a private IP address. 255.255.255.0 denotes the network mask which decides the potential size of your network and the number 192.168.0.255 denotes the broadcast address and lastly, the up keyword is the flag which loads the module related to this particular Ethernet card and makes it ready to receive and send data.

Earlier, Ethernet interface was identified as eth0, eth1 and so on. However, if you are using latest Fedora Linux, the Ethernet interface is identified as p2p1, p2p2 and so on.


Gathering network related data


When used without any parameters, the command ifconfig shows details of the network interfaces that are up and running in your computer. In my machine which has a single Ethernet card and a loop back interface, I get the following output.


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:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

p2p1      Link encap:Ethernet  HWaddr 00:1C:C0:AE:B5:E6  
          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21c:c0ff:feae:b5e6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41620 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40231 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:21601203 (20.6 MiB)  TX bytes:6145876 (5.8 MiB)
          Interrupt:21 Base address:0xe000 


Analysis of ifconfig output


Lets take a closer look at the output fields of the ifconfig command.

  • Link encap:Ethernet - This denotes that the interface is an Ethernet related device.
  • HWaddr 00:70:40:42:8A:60 - This is the hardware address or MAC address which is unique to each Ethernet card which is manufactured. Usually, the first half part of this address will contain the manufacturer code which is common for all the Ethernet cards manufactured by the same manufacturer and the rest will denote the device Id which should not be the same for any two devices manufactured at the same place.
  • inet addr - indicates the machine IP address
  • Bcast - denotes the broadcast address
  • Mask - is the network mask which we passed using the netmask option (see above).
  • UP - This flag indicates that the kernel modules related to the Ethernet interface has been loaded.
  • BROADCAST - Denotes that the Ethernet device supports broadcasting - a necessary characteristic to obtain IP address via DHCP.
  • NOTRAILERS - indicate that trailer encapsulation is disabled. Linux usually ignore trailer encapsulation so this value has no effect at all.
  • RUNNING - The interface is ready to accept data.
  • MULTICAST - This indicates that the Ethernet interface supports multicasting. Multicasting can be best understood by relating to a radio station. Multiple devices can capture the same signal from the radio station but if and only if they tune to a particular frequency. Multicast allows a source to send a packet(s) to multiple machines as long as the machines are watching out for that packet.
  • MTU - short form for Maximum Transmission Unit is the size of each packet received by the Ethernet card. The value of MTU for all Ethernet devices by default is set to 1500. Though you can change the value by passing the necessary option to the ifconfig command. Setting this to a higher value could hazard packet fragmentation or buffer overflows. Do compare the MTU value of your Ethernet device and the loopback device and see if they are same or different. Usually, the loopback device will have a larger packet length.
  • Metric - This option can take a value of 0,1,2,3... with the lower the value the more leverage it has. The value of this property decides the priority of the device. This parameter has significance only while routing packets. For example, if you have two Ethernet cards and you want to forcibly make your machine use one card over the other in sending the data. Then you can set the Metric value of the Ethernet card which you favor lower than that of the other Ethernet card. I am told that in Linux, setting this value using ifconfig has no effect on the priority of the card being chosen as Linux uses the Metric value in its routing table to decide the priority.
  • RX Packets, TX Packets - The next two lines show the total number of packets received and transmitted respectively. As you can see in the output, the total errors are 0, no packets are dropped and there are no overruns. If you find the errors or dropped value greater than zero, then it could mean that the Ethernet device is failing or there is some congestion in your network.
  • collisions - The value of this field should ideally be 0. If it has a value greater than 0, it could mean that the packets are colliding while traversing your network - a sure sign of network congestion.
  • txqueuelen - This denotes the length of the transmit queue of the device. You usually set it to smaller values for slower devices with a high latency such as modem links and ISDN.
  • RX Bytes, TX Bytes - These indicate the total amount of data that has passed through the Ethernet interface either way. Taking the above example, I can fairly assume that I have used up 31.6 MB in downloading and 2.5 MB uploading which is a total of 37.1 MB of bandwidth. As long as there is some network traffic being generated via the Ethernet device, both the RX and TX bytes will go on increasing.
  • Interrupt - From the data, I come to know that my network interface card is using the interrupt number 9. This is usually set by the system.

The values of almost all the options listed above can be modified using the requisite ifconfig options.

For example, you can pass the option trailers to the ifconfig command to enable trailer encapsulation.

Or you can change the packet size by using the mtu option along with the new value and so on.

But in majority of the cases, you always accept the default values.

Learning to use the right command is only a minuscule part of the job of a network administrator. The major part of the job is in analysing the data returned by the command and arriving at the right conclusions.

Find the speed of your Ethernet card in Linux

October 27, 2005 8 comments
For logging on to the net or for attaching as a node on a LAN, your computer needs a network card. The network card forms the interface between your computer and the network. There are different kinds of network cards available in the market depending on its speed and other features. Here is a tip to find out the characteristics of your network card.

If you want to find what type of network card is used, its speed, on which IRQ it is listed, and the chip type used, you use the following command :

# dmesg |grep eth0

Here eth0 is the first network card. If you have additional cards, it will be named eth1, eth2 and so on. And here is the output of the above command :

divert: allocating divert_blk for eth0
eth0: RealTek RTL8139 at 0xd800, 00:80:48:34:c2:84, IRQ 9
eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
divert: freeing divert_blk for eth0
divert: allocating divert_blk for eth0
eth0: RealTek RTL8139 at 0xd800, 00:90:44:34:a5:33, IRQ 9
eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
eth0: no IPv6 routers present
...

Please take a closer look at the above listing. The output data identifies my Ethernet card is a RealTek RTL8139 chipset based card on IRQ 9 (Interrupt Request). Its speed is 100 Mbps and is a full-duplex card. And the link is up.

mii-tool


As is the philosophy of Linux, there is more than one way of finding the same information. Linux also comes with a cute sounding tool called mii-tool which can also be used to get the same information about your network card.

# mii-tool -v eth0

eth0: negotiated 100baseTx-FD, link ok
product info: vendor 00:00:00, model 0 rev 0
basic mode:   autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD
             10baseT-HD
...

Here -v is verbose mode. From the above listed output, one can see that the Ethernet card is working as a 100baseTX, FD (Full Duplex) card which can work in the following modes :

  • 100 Mbps Speed (Full duplex or half duplex ) or
  • 10 Mbps speed (Full duplex or half duplex).

And it uses auto-negotiation to bring up the link. You can call the above device as a 10/100 NIC.

mii-tool is obsolete. Valid media are only 100baseT4, 100baseTx-FD, 10baseT-FD, and 10baseT-HD ethernet cards. You are encouraged to use the more useful ethtool instead.


ethtool


ethtool is a more powerful cousin to mii-tool. The following is a simple use of ethtool.

# ethtool eth0

You get an output as shown below.

Settings for eth0:
  Supported ports: [ TP MII ]
  Supported link modes:   10baseT/Half 10baseT/Full
                          100baseT/Half 100baseT/Full
  Supports auto-negotiation: Yes
  Advertised link modes:  10baseT/Half 10baseT/Full
                          100baseT/Half 100baseT/Full
  Advertised auto-negotiation: Yes
  Speed: 100Mb/s
  Duplex: Full
  Port: MII
  PHYAD: 32
  Transceiver: internal
  Auto-negotiation: on
  Supports Wake-on: pumbg
  Wake-on: p
  Current message level: 0x00000007 (7)
  Link detected: yes

In the output above, full duplex, half duplex and auto-negotiation have the following meanings.

Full Duplex - Logic that enables concurrent sending and receiving. This is usually desirable and enabled when your computer is connected to a switch.

Half Duplex - This logic requires a card to only send or receive at a single point of time. When your machine is connected to a Hub, it auto-negotiates itself and uses half duplex to avoid collisions.

Auto-negotiation - This is the process of deciding whether to work in full duplex mode or half duplex mode. An Ethernet card supporting auto-negotiation will decide for itself which mode is the optimal one depending on the network it is attached to.

Setting up multiple IP addresses on a single NIC

May 20, 2005 3 comments
In linux, you can bind multiple IP addresses on a single NIC. This is usually done in case you are using your linux machine as a web server and is hosting multiple domains and you want to bind each domain to a unique IP address. This is how it is done.

Let us assume that you already have a NIC which is bound with a static IP address. Then you will have a file called /etc/sysconfig/network-scripts/ifcfg-eth0 .My ifcfg-eth0 file has the following entries:
# File: ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.0
HWADDR=00:80:48:34:C2:84

Now to bind another IP address to the same NIC, I create a copy of the above file ifcfg-eth0 and name it as ifcfg-eth0:1
# cd /etc/sysconfig/networking-scripts
# cp ifcfg-eth0 ifcfg-eth0:1

Now just change the values of the DEVICE and IPADDR in the file as follows:
# File: ifcfg-eth0:1
DEVICE=eth0:1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.5
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.0
HWADDR=00:80:48:34:C2:84
And lastly, restart the networking service. If you are using RedHat, then it is as simple as :
# service network restart

Note: If you do not know how to configure a NIC, see my previous posts - How to install a network card in Linux and How to assign an IP address.

How to Change Hostname in Linux

January 12, 2005 2 comments
A hostname is a label that is assigned to a device connected to a computer network and that is used to identify the device in various forms of electronic communication such as the World Wide Web, e-mail or Usenet.

The following are the steps you need to execute to change the hostname of your device in Linux.