Networking and Remote Management Basics - Linux Class 13
Common Networking Commands
ifconfig
: Displays network interface configuration (Linux).ping <ip>
: Tests connectivity to a specific IP address.hostname
: Shows the system's hostname.nslookup <ip>
: Resolves an IP to a hostname.nslookup <hostname>
: Resolves a hostname to an IP address.traceroute
: Tracks the path network packets take to a destination.netstat
: Displays network statistics (connections, ports, etc.).- Edit DNS entries: Modify
/etc/resolv.conf
(e.g.,nameserver 8.8.8.8
).
Enable/Disable Network Interface
- Enable:
ip link set <port> up
(e.g.,ip link set eth0 up
). - Disable:
ip link set <port> down
(e.g.,ip link set eth0 down
).
Remote Management Tools
- Windows to Linux:
- PuTTY, MobaXterm, SuperPuTTY (uses SSH, Telnet, etc.).
- Linux to Linux:
- SSH:
ssh username@ipaddress
(e.g.,ssh [email protected]
).
- SSH:
- Windows to Windows:
- RDP (Remote Desktop Protocol).
Common Port Numbers
- SSH: 22
- Telnet: 23
- HTTP: 80
- HTTPS: 443
- FTP: 21
- SFTP: 22
What is a Port Number and Its Impact on Connectivity?
A port number is a 16-bit number (0-65535) that identifies specific services or applications on a device within a network. It works with an IP address to route traffic to the correct process.
- Examples:
- Port 80: HTTP (web browsing).
- Port 443: HTTPS (secure web browsing).
- Impact: If a port is blocked (e.g., by a firewall) or not open on the target machine, connectivity fails. The port must match the service (e.g., SSH won’t work on port 80).
File Transfer Between Machines
- Within Linux:
cp file1 target_dir
: Copy a file.cp -r dir1 target_dir
: Copy a directory recursively.
- Linux to Linux:
scp file_name username@ip:target_dir
(e.g.,scp file1 [email protected]:/home/
).
- Windows to Linux:
- WinSCP: GUI tool using SFTP (port 22).
- Windows to Windows:
- Copy-paste via RDP (Ctrl+C, Ctrl+V).
Answers to Key Questions
1. Passwordless Login to Remote Host Using SSH
Steps:
- Generate SSH key pair:
ssh-keygen
(press Enter for defaults). - Copy public key to remote host:
ssh-copy-id username@ipaddress
(e.g.,ssh-copy-id [email protected]
). - Test:
ssh username@ipaddress
—no password required.
2. HTTP and HTTPS
- HTTP: HyperText Transfer Protocol, unencrypted, uses port 80 for web pages.
- HTTPS: HTTP Secure, encrypted with SSL/TLS, uses port 443.
- Difference: HTTPS ensures privacy and security with encryption; HTTP does not.
3. What is an API?
An API (Application Programming Interface) is a set of rules and tools allowing software applications to communicate. It acts as a middleman for data exchange (e.g., a weather app fetching data from a server).
4. Different Types of APIs
- REST: Lightweight, stateless, uses HTTP methods.
- SOAP: Structured, protocol-based, uses XML.
- GraphQL: Query-based, flexible data retrieval.
- RPC: Remote Procedure Call, executes functions remotely.
5. HTTP Methods
- GET: Retrieve data from a server.
- POST: Send data to a server (e.g., form submission).
- PUT: Update existing data on a server.
- DELETE: Remove data from a server.
- PATCH: Partially update data on a server.
6. HTTPS Status Codes
- 200: OK (success).
- 201: Created (resource created successfully).
- 400: Bad Request (client error).
- 401: Unauthorized (authentication required).
- 403: Forbidden (access denied).
- 404: Not Found (resource missing).
- 500: Internal Server Error (server issue).
7. Postman Tool
Postman is a tool for testing APIs. It allows you to:
- Send HTTP requests (GET, POST, etc.).
- Test responses (status codes, data).
- Automate API testing with scripts.
- Save and organize API requests.