Unit2 LinuxNetworking Notes
Unit2 LinuxNetworking Notes
1. Linux Networking
- Network Packets: Data is transmitted over networks in small units called packets. Each packet
contains headers (with source/destination addresses) and payload (actual data).
- TCP/IP Protocol Suite: The suite of protocols used for communication on the internet and local
networks. TCP (Transmission Control Protocol) ensures reliable, ordered delivery of data, while IP
(Internet Protocol) handles addressing and routing of packets.
- Address Resolution Protocol (ARP): ARP maps a network layer address (e.g., IP address) to a link
layer address (e.g., MAC address). When a computer wants to send a packet to another computer
on the same LAN, ARP finds the recipient's MAC address.
- IP Addresses and Network Mask: IP addresses uniquely identify devices on a network. A subnet
mask divides the IP address into network and host portions, determining which part of the IP is the
network address and which part is the host address.
- Subnets and Routing: Subnetting divides a larger network into smaller subnetworks, improving
efficiency and security. Routers route packets between different subnets based on routing tables.
- IPv4 and Network Classes: IPv4 addresses are 32-bit numbers. Historically, IPv4 was divided into
classes A, B, and C to designate network and host portions. For example, Class A addresses have
the first octet ranging from 1 to 126.
- Ports: A port is a logical construct to distinguish different network services on the same IP address.
Well-known ports (0-1023) include 80 for HTTP, 22 for SSH, etc.
- arp: Manipulates the ARP cache. You can view the current ARP entries with 'arp -a' and manually
add entries with 'arp -s <IP> <MAC>'.
- ifconfig (or ip addr): Displays and configures network interfaces. For example, 'ifconfig eth0
192.168.1.10 netmask 255.255.255.0 up' assigns an IP address to eth0.
- ip (from iproute2): A more modern tool replacing ifconfig. Use 'ip addr', 'ip link', 'ip route', etc., to
manage interfaces, links, and routing tables.
- netstat: Displays network connections, routing tables, and interface statistics. For example, 'netstat
-tuln' lists all listening TCP/UDP ports.
These commands help in verifying connectivity, diagnosing issues, and configuring network
parameters.
- telnet: A protocol and tool to connect to remote hosts on a specified port. Telnet is unencrypted
and largely deprecated in favor of SSH.
- rsh (Remote Shell): Allows execution of commands on remote machines without logging in
explicitly. rsh is insecure and replaced by RSH alternatives.
- ftp (File Transfer Protocol): A standard protocol to transfer files. Modern systems often use secure
alternatives like SFTP.
- rcp (Remote Copy): Copies files between hosts in an unencrypted manner. Replaced by 'scp'
(secure copy) which uses SSH.
- ssh (Secure Shell): Secure and encrypted protocol to log in and execute commands on remote
systems. SSH keys can be used for authentication.
- rsync: Efficient tool for syncing files and directories between systems. Rsync transfers only the
changed parts of files.
- inetd.conf: Configuration file for the Internet Super-Server (inetd or xinetd). It listens for incoming
service requests (e.g., telnet, ftp) and launches the appropriate daemon.
- Opening and Closing Ports: Administrators can open or close network ports by configuring firewall
rules (e.g., using iptables, firewalld, or ufw) or by editing service configurations.
2. Network File System (NFS)
Network File System (NFS) allows files and directories to be shared over a network. It enables users
to access files on remote machines as if they were on local disks.
- File System Sharing: NFS uses the concept of exporting directories from the server and mounting
them on clients. The server lists the directories to export in /etc/exports.
- Remote Procedure Call (RPC) Services: NFS relies on RPC to handle communication between
client and server. The rpcbind service maps RPC program numbers to network ports.
- NFS Server and Client Sides: The server runs NFS daemons (e.g., nfs-server, rpcbind). Clients
use the 'mount' command with NFS type to mount remote exports (e.g., 'mount -t nfs server:/export
/mnt').
- Static Mount and Auto Mount Configuration: Static mounts use /etc/fstab entries. Auto-mounting
can be achieved with autofs, configuring /etc/auto.master and /etc/auto.<map>.
- Troubleshooting NFS: Common issues include firewall blocking NFS ports (2049), incorrect export
permissions, and network connectivity problems. Use 'showmount -e server' to view exports and
'mount' to check mounted filesystems.
- Security and Optimization: NFSv4 includes stronger security features like Kerberos authentication.
Use options like 'no_root_squash', 'ro', and 'rw' to control client permissions. For performance,
consider using smaller block sizes, enabling async writes, and tuning rsize/wsize options.
3. Network Information Service (NIS)
Network Information Service (NIS), originally called Yellow Pages (YP), provides a centralized
authentication and directory service in Unix/Linux environments. It allows multiple Unix systems to
share common configuration files.
- Centralized Authentication Systems: NIS centralizes user account information (e.g., /etc/passwd,
/etc/group) on a master server, reducing administrative overhead.
- Sharing User and Host Information Over the Network: NIS maintains various maps (databases)
including passwd.byname, group.byname, hosts.byname, etc., to provide consistent user and host
information across clients.
- NIS Server and Client Sides: The NIS server (ypserv, ypbind) manages and distributes maps.
Clients run ypbind to connect to the server and use commands like 'ypcat' to view NIS maps.
- Configuration:
1. On the server, install NIS packages (e.g., 'sudo apt-get install nis').
2. Configure /etc/default/nis (Debian) or /etc/sysconfig/nis (Red Hat) to set NIS domain name.
3. Run 'ypinit -m' to create NIS maps.
4. On clients, set the NIS domain name and configure /etc/yp.conf to point to the server.
5. Start ypbind service on clients.
- Compatibility Mode: NIS+ is the successor to NIS with stronger security, but NIS compatibility
mode allows NIS+ servers to serve traditional NIS clients.
- Netgroup: NIS netgroups allow grouping of users or hosts for permissions. Defined in the netgroup
map.
- Security Issues: NIS transmits data unencrypted, making it vulnerable to interception. Restrict NIS
servers to trusted networks and consider using NIS+ or LDAP for stronger security.