C7. Networking and Remote Access
C7. Networking and Remote Access
C7. Networking and Remote Access
Chapter 7.
NETWORKING AND REMOTE
ACCESS
1-1
Main contents
➢ Networking
▪ Basics and requirements
▪ Networking with TCP/IP
▪ IPv6
▪ Network Organization
▪ Network configuration (Wired and Wireless)
➢ Remote Access
▪ Setting up a SSH server
▪ Using SSH tools
▪ Virtual Network Computing (VNC)
1-2
Hardware
1-3
Initializing New Network Hardware
➢ Unless support for a particular NIC is built in to your
kernel (in /dev), Linux must be told to load a specific
kernel module to support your NIC.
▪ More than100 such modules are located in the
/lib/modules/5.X.XX-XX/kernel/net directory (where X.XX-XX
is your version of the kernel).
➢ Using modprobe to manually load kernel modules
1-5
TCP/IP Addressing: IPv4
➢ IP Address Classes
1-6
TCP/IP Addressing: IPv6
➢ E.g
• F734:0000:0000:0000:3458:79B2:D07B:4620
• 2002:0000:0000:0000:0000:0000:0A00:0001
(2002::10.0.0.1 or 2002::A00:1)
➢ Special-use addresses
• ::1/128 is the loopback address
• ::/128 is the unspecified address
• ::/0 is the default unicast route address.
• ff00::/8 are multicast addresses.
Localhost or loopback interface
1-8
TCP/IP Addressing
➢ Net & Subnet
➢ Net & Subnet mask
IP
▪ Note that these ports are not set in stone, and you can set up
your server to respond to different ports.
• E.g. , change SSH port in /etc/ssh/sshd_config to port 2224 (after
restarting service sudo service ssh restart)
1-10
TCP/IP Addressing
➢ Broadcast, Unicast, and Multicast Addressing
1-11
Network checking
➢ Localhost (or Loopback) interface
▪ ip address show
~$ ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
group default
qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
1-12
Network checking
➢ Localhost (or Loopback) interface
▪ ifconfig
~$ ifconfig
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:270 errors:0 dropped:0 overruns:0 frame:0
TX packets:270 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:20748 (20.7 KB) TX bytes:20748 (20.7 KB
1-13
Network checking
➢ Configuring the Loopback Interface Manually
1-14
Checking connection
➢ Using commands
▪ ping
$ping -c 3 localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.047 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.060 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.045 ms
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2030ms
rtt min/avg/max/mdev = 0.045/0.050/0.060/0.010 ms
1-15
Checking connection
➢ Using commands
▪ traceroute
$traceroute google.com
traceroute to google.com (74.125.225.99), 30 hops max, 60 byte packets
1 Cisco02420 (192.168.1.1) 0.149 ms 0.181 ms 0.304 ms
2 10.2.0.1 (10.2.0.1) 3.190 ms 3.227 ms 3.217 ms
3 65.201.51.216.sta.southslope.net (216.51.201.65) 3.397 ms 3.611 ms 3.720 ms
4 ss-dsl-sec1.nl.southslope.net (167.142.151.30) 3.622 ms 3.637 ms 3.649 ms
5 167.142.50.13 (167.142.50.13) 6.660 ms 6.665 ms 6.678 ms
6 ins-dc2-et-8-4.desm.netins.net (167.142.67.17) 6.599 ms 6.503 ms 7.482 ms
7 ins-db3-te-0-7-0-0.desm.netins.net (167.142.67.182) 7.845 ms 5.145 ms 5.131 ms
1-16
Checking connection
➢ Using commands
▪ $mtr google.com (combine ping and traceroute)
1-17
Using network configuration tools
➢ Using GUI
▪ Network Manager
➢ Command line
▪ ifconfig
▪ ip/ip route
▪ route
▪ netstat
1-18
Using network configuration tools
➢ ifconfig
ifconfig [network device] options
E.g.
route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
adds the normal loopback entry, using netmask 255.0.0.0 and associated with the
"lo" device
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
adds a route to the local network 192.56.76.x via "eth0". The word "dev" can be
omitted here.
Option Output
-g Displays the multicast groups configured
-i Displays the interfaces configured by ifconfig
-s Lists a summary of activity for each protocol
-v Gives verbose output, listing both active and inactive sockets
-c Updates output every second (good for testing and
troubleshooting)
-e Gives verbose output for active connections only
-C Displays information from the route cache and is good for looking
at past connections
1-22
Network Configuration Files
File Content
/etc/hosts A listing of addresses, hostnames, and aliases
/etc/services Network service and port connections
/etc/nsswitch.conf Linux network information service configuration
/etc/resolv.conf Domain Name System (DNS) domain (search) settings
/etc/host.conf Network information search order (by default, /etc/hosts
and then DNS)
Starting with 17.10, Ubuntu made another big switch away from
resolvconf to netplan. Instead of using /etc/network/interfaces,
you now find network configuration in /etc/netplan/*.yaml files.
• Using netplan follows pages 353-355 in textbook
1-23
Network Configuration Files
1-25
Wireless Networking
1-26
Wireless Networking
1-27
Practice
➢ Check route to facebook.com
➢ Change ip address of the Ethernet interface
➢ Scan wireless network
➢…
1-28
Remote Access
1-29
Remote Access
➢ Setting up an SSH server
➢ SSH tools
➢ Virtual network computing (VNC)
1-30
Setting Up SSH server
➢ If SSH is not installed already, install the OpenSSH
server by adding the openssh-server package
➢ Configure the server
/etc/ssh/sshd_config
➢ Configure the client
/etc/ssh/ssh_config
➢ Two different versions of SSH exist: SSH1 and SSH2. The latter is
newer and more secure, comes with more features, and is the
default in Ubuntu.
https://devconnected.com/how-to-install-and-enable-ssh-server-on-
ubuntu-20-04/
1-31
SSH Tools
➢ ssh: Secure Shell command that connects to other machines
ssh -p <port> <username>@<ip_address>
$ssh -p 22 minh@127.0.0.1
▪ sshd: the server daemon accepts incoming SSH connections
▪ $ssh-keygen –t dsa: create key for for remote user login
▪ After the key is generated, change the directory to .ssh (cd ~/.ssh), which is a
hidden directory where your key is stored and that keeps a list of safe SSH
hosts.
1-32
SSH Tools
1-33
VNC
➢ Settings → Sharing
1-35