0% found this document useful (0 votes)
56 views

UNIX Network

Ethernet interfaces are identified as ethx, where x is a number. Ifconfig and lshw can identify interfaces. IP addresses can be configured temporarily using ifconfig and route, or dynamically with DHCP by editing /etc/network/interfaces. Static IP addresses are also configured in /etc/network/interfaces by specifying the address, netmask, and gateway. The loopback interface lo has a default IP of 127.0.0.1.

Uploaded by

dag
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

UNIX Network

Ethernet interfaces are identified as ethx, where x is a number. Ifconfig and lshw can identify interfaces. IP addresses can be configured temporarily using ifconfig and route, or dynamically with DHCP by editing /etc/network/interfaces. Static IP addresses are also configured in /etc/network/interfaces by specifying the address, netmask, and gateway. The loopback interface lo has a default IP of 127.0.0.1.

Uploaded by

dag
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Ethernet Interfaces

Ethernet interfaces are identified by the system using the naming convention of ethx, where
x represents a numeric value. The first Ethernet interface is typically identified as eth0, the
second as eth1, and all others should move up in numerical order.

Identify Ethernet interfaces

To quickly identify all available Ethernet interfaces, you can use the ifconfig command as
shown below.

$ifconfig - a | grep eth


Etho Link encap: Ethernet HWaddr 00:15:c5:4a:16:5a
Another application that can help identify all network interfaces available to your system is
the lshw command.

IP addressing
The following section describes the process of configuring your systems IP address and
default gateway needed for communicating on a local area network and the intenet.

Temporary IP address assignment


For temporary network configurations, you can use standard commands such as ip, ifconfig
and route, which are also found on most other Linux operating systems. These commands
allow you configure settings which take effect immediately; however they are not persistent
and will be lost after a reboot.
To temporarily configure an IP address, you can use the ifconfig command in the following
manner. Just modify the IP address and subnet mask to match your network requirements.
$sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0
To verify the IP address configuration of eth0, you can use the ifconfig command in the
following manner.
$ifconfig eth0
To configure a default gateway, you can use the route command in the following manner.
Modify the default gateway address to match your network requirements.
$sudo route add default gw 10.0.0.1 eth0
To verify your default gateway configuration, you can use the route command in the
following manner.
$route - n
If you require DNS for your temporary network configuration, you can add DNS server IP
addresses in the file /etc/resolv.conf. the example below shows how to enter two DNS
servers to /etc/resolv.conf, which should be changed to servers appropriate for your
network. A more lengthy description of DNS client configuration is in the following section.
$nameserver 8.8.8.8
$nameserver 8.8.4.4
1
If you no longer need this configuration and wish to purge all IP configuration from an
interface, you can use the ip command with the flush option as shown below.
$ip addr flush eth0
Flushing the IP configuration using the ip command doesn’t clear the contents of
/etc/resolv.conf. You must remove or modify those entries manually.

Dynamic IP address assignment (DHCP Client):


To configure your server to use DHCP for dynamic address assignment, add the dhcp
method to the inet address family statement for the appropriate interface in the file
/etc/network/interfaces. The example below assumes you are configuring your first
Ethernet interface identified as eth0.
auto eth0
iface eth0 inet dhcp

By adding an interface configuration as shown above, you can manually enable the interface
through the ifup command which initiates the DHCP process via dhclient.
$sudo ifup eth0
To manually disable the interface, you can use the ifdown command, which in turn will
initiate the DHCP release process and shut down the interface.
$sudo ifdown eth0

Static IP address assignment:

To configure your system to use a static IP address assignment, add the static method to the
inet address family statement for the appropriate interface in the file
/etc/network/interfaces. The example below assumes you are configuring your first
Ethernet interface identified as eth0. Change the address, netmask, and gateway values to
meet the requirements of your network.

auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1

By adding an interface configuration as shown above, you can manually enable the interface
through the ifup command.
$sudo ifup eth0
To manually disable the interface, you can use the ifdown command.
$sudo ifdown eth0

2
Loopback interface:

The loopback interface is identified by the system as lo and has a default IP address of
127.0.0.1. It can be viewed using the ifconfig command.
$ifconfig lo
By default, there should be two lines in /etc/network/interfaces responsible for
automatically configuring your loopback interface. It is recommended that you keep the
default settings unless you have a specific purpose for changing them. An example of the
two default lines are shown below.
auto lo
iface lo inet loopback

netstat

Displays contents of /proc/net files. It works with the Linux network subsystem; it
will tell you what the status of ports are i.e. open, closed, waiting, masquerade connections.
It will also display various other things. It has many different options.

ping

the ping command sends echo requests to the host you specify on the command line, and
lists the response received their round trip time. You can use ping as:

$ping [ip address]


Or
$ping [host name]
Note: to stop ping use ctrl+C

traceroute

traceroute will show the route of a packet. It attempts to list the series of hosts through
which your packets travel on their way to a given destination.
$traceroute machine_name
Or $traceroute ip_address

nmap

“network exploration tool and security scanner”. nmap is a very advanced network tool
used to query machines (local or remote) as to whether they are up and what ports are
open on these machines.
$nmap machine_name
This would query your own machine as to what ports it keeps open.

You might also like