Introduction to Linux Networking.ppt
-
Upload
networksguy -
Category
Documents
-
view
4.398 -
download
1
Transcript of Introduction to Linux Networking.ppt
Knoppix
• Knoppix is a live Linux system that is bootable from CD or DVD– Fully featured Linux system– Automatic hardware detection– Runs completely from CD and RAM
Opening a root shell
• Click on the konsole icon
Opening a root shell
• Type “su” at the prompt
Enumerating network devices
• Use the ifconfig command to list the network devices
root@3[~]# ifconfig -a
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:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1092 (1.0 KiB) TX bytes:1092 (1.0 KiB)
lo - Loopback device
• The loopback device is present on virtually any IP based machine– Any data sent to the loopback device is
immediately returned– Used mainly for testing, but has some use in
specific network applications– Strictly internal device, always assigned the
127.0.0.1 address
Enumerating network devices
• Use the ifconfig command to list the network devices
root@3[~]# ifconfig -aeth0 Link encap:Ethernet HWaddr 00:02:B3:8C:4C:ED inet addr:192.168.1.254 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::202:b3ff:fe8c:4ced/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:741 errors:0 dropped:0 overruns:0 frame:0 TX packets:895 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:82106 (80.1 KiB) TX bytes:548518 (535.6 KiB)
ethX – Ethernet device
• The ethernet devices are physical network cards operating on the ethernet standard– Most common network device– Multiple devices supported (eth0, eth1, etc.)– Each card has a globally unique hardware
address assigned to it, the MAC (Media Access Control) address
Other devices
• There are many other possible devices– pppX – Point to Point devices used in dialup
internet services or VPN settings– wlanX – Wireless devices, similar to ethernet
but using a different communication standard
Configuring network devices
• The file /etc/network/interfaces stores the configuration information for all network devices
root@3[~]# cat /etc/network/interfaces
# /etc/network/interfaces -- configuration file for ifup(8),ifdown(8)
# The loopback interface
# automatically added when upgrading
auto lo
iface lo inet loopback
Configuring network devices
• Enter the following for a static configuration of eth0
auto eth0
iface eth0 inet static
address 192.168.1.XXX
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
root@3[~]# nedit /etc/network/interfaces
Configuring network devices
• The address line specifies which IP address will be assigned to this machine– Must be unique within the local network
auto eth0
iface eth0 inet static
address 192.168.1.XXX
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
Configuring network devices
• The broadcast line specifies which address will be used for special broadcast packets– All machine on the local network should be
using the same broadcast address– This address should not otherwise be in use
auto eth0
iface eth0 inet static
address 192.168.1.XXX
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
Configuring network devices
• The netmask line specifies what addresses are consider on the local network– The address line and the netmask line combine
to form the LAN (local area network)
auto eth0
iface eth0 inet static
address 192.168.1.XXX
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
Configuring network devices
• The gateway line specifies what address is used to forward non local packets– This address should be a router capable of
routing traffic to the internet at large
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
Configuring network devices
• Enter the following for a dynamic (DHCP) configuration of eth0– Will attempt to query a local DHCP server to
provide the network configuration
root@3[~]# nedit /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
Configuring network devices
• Once the configuration is finished use the ifup and ifdown commands to control the network device
• Bring an interface down with ifdown
• Bring an interface up with ifup
root@3[~]# ifdown eth0
root@3[~]# ifup eth0
Testing the network
• The ping command is a useful tool for testing a network configuration– Uses an special ICMP (Internet Control
Message Protocol) packet to ‘ping’ a given address
– A machine that receives a ‘ping’ packet will send a similar ‘ping’ packet back
– Universally available, requires no running services
Testing the network
• First attempt to ping the gatewayroot@4[~]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=128 time=0.129 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=128 time=0.148 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=128 time=0.148 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=128 time=0.150 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=128 time=0.154 ms
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3996ms
rtt min/avg/max/mdev = 0.129/0.145/0.154/0.017 ms
root@4[~]#
Testing the network
• Ping a non-existent machineroot@4[~]# ping 192.168.1.55
PING 192.168.1.55 (192.168.1.55) 56(84) bytes of data.
From 192.168.1.50 icmp_seq=1 Destination Host Unreachable
From 192.168.1.50 icmp_seq=2 Destination Host Unreachable
From 192.168.1.50 icmp_seq=3 Destination Host Unreachable
From 192.168.1.50 icmp_seq=4 Destination Host Unreachable
From 192.168.1.50 icmp_seq=5 Destination Host Unreachable
--- 192.168.1.55 ping statistics ---
7 packets transmitted, 0 received, +6 errors, 100% packet loss,
time 6015ms, pipe 3
root@4[~]#
Testing the network
• Ping a known local addressroot@4[~]# ping 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=64 time=0.035 ms
64 bytes from 192.168.1.100: icmp_seq=4 ttl=64 time=0.039 ms
64 bytes from 192.168.1.100: icmp_seq=5 ttl=64 time=0.038 ms
--- 192.168.1.100 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3998ms
rtt min/avg/max/mdev = 0.035/0.036/0.039/0.007 ms
root@4[~]#
Testing the network
• Ping a non-local addressroot@4[~]# ping 129.97.114.212
PING 129.97.114.212 (129.97.114.212) 56(84) bytes of data.
64 bytes from 129.97.114.212: icmp_seq=1 ttl=253 time=2.09 ms
64 bytes from 129.97.114.212: icmp_seq=2 ttl=253 time=1.96 ms
64 bytes from 129.97.114.212: icmp_seq=3 ttl=253 time=2.73 ms
64 bytes from 129.97.114.212: icmp_seq=4 ttl=253 time=2.00 ms
64 bytes from 129.97.114.212: icmp_seq=5 ttl=253 time=2.04 ms
--- 129.97.114.212 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 1.964/2.168/2.734/0.287 ms
root@4[~]#
Configuring DNS
• DNS (Domain Name System) is the system for resolving host names into IP addresses– Globally administered (by ICANN)– Locally distributed (per domain)
• UW runs a DNS– Services queries for any xxx.uwaterloo.ca– Redirects other queries (i.e. www.google.ca)
for the entire university
Configuring DNS
• The local DNS information is stored in /etc/resolv.conf– All applications reference this file to resolve
hostnames into IP address
root@3[~]# nedit /etc/resolv.conf
nameserver 129.97.128.10
nameserver 129.97.128.100
Configuring DNS
• Ping a named machineroot@4[~]# ping ns1.uwaterloo.ca
PING ns1.uwaterloo.ca (129.97.128.10) 56(84) bytes of data.
64 bytes from ns1.uwaterloo.ca (129.97.128.10): icmp_seq=1 ttl=253 time=81.2 ms
64 bytes from ns1.uwaterloo.ca (129.97.128.10): icmp_seq=2 ttl=253 time=2.28 ms
64 bytes from ns1.uwaterloo.ca (129.97.128.10): icmp_seq=3 ttl=253 time=2.34 ms
64 bytes from ns1.uwaterloo.ca (129.97.128.10): icmp_seq=4 ttl=253 time=2.29 ms
64 bytes from ns1.uwaterloo.ca (129.97.128.10): icmp_seq=5 ttl=253 time=1.25 ms
--- ns1.uwaterloo.ca ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4003ms
rtt min/avg/max/mdev = 1.252/17.886/81.258/31.688 ms
root@4[~]#
Client/Server communication
• Communication on an IP network follows the client/server model– A server is actively listening for connection
from a client– A client will explicitly start a connection to the
server– Once established, this connection is referred to
as a socket
Client/Server communication
• A socket is comprised of the following– Server IP address– Server port– Client IP address– Client port
• However, once established the notion of server and client are often irrelevant
Client/Server communication
• There are many network connections (sockets) being used simultaneously
• Ports are used to associate communication with a particular application– A 16 bit integer (0-65535)– Dynamically allocated for client purposes– Fixed numbers for many server applications
• Web (80), FTP (20), Email (25), DNS (53), etc.
Client/Server communication
• Using the netcat utility start a server listening on a specific port
root@4[~]# netcat -l -p YYY
Client/Server communication
• Using the netcat utility start a client connection to the server with the server IP address and port
root@4[~]# netcat 192.168.1.XXX YYY
Client/Server communication
• Any text typed in the client window will show up in the server window and vice versa
root@4[~]# netcat -l -p YYY
Hello
Goodbye
root@4[~]# netcat 192.168.1.XXX YYY
Hello
Goodbye