IP and Hostname Management
IP Address Fundamentals
Network-connected computers require unique addresses for communication. IP addresses exist in two primary versions: IPv4 and IPv6. IPv4 addreses follow the format a.b.c.d where each component ranges from 0 to 255 (e.g., 192.168.88.101).
Checking Local IP Address
Method 1: Using ifconfig
ifconfig
Method 2: Using ip addr
ip addr
Special IP Addresses
- 127.0.0.1: Local loopback address referencing the current machine
- localhost: Hostname equivalent to 127.0.0.1
- 0.0.0.0: Wildcard address allowing connections from any IP
Hostname Configuration
View Current Hostname
hostname
Modify Hostname via Command
hostnamectl set-hostname new-hostname
Modify Hostname via Configuration File
vim /etc/hostname
Persistent Hostname Configuration
Edit /etc/hosts to map IP addresses to hostnames:
# IP_address hostname
192.168.66.101 my-server
Update network configuration in /etc/sysconfig/network:
NETWORKING=yes
HOSTNAME=my-server
Apply changes with system reboot.
Static IP Configurationn
Benefits of Static IP Assignment
- Consistent remote access via SSH tools
- Stable cluster configurations in multi-server environments
- Reliable service dependencies and virtual machine networking
Configuring Static IP
- Configure VMware Virtual Network Editor
- Adjust network settings
- Define IP address allocation range
- Set gateway parameters
- Edit network interface configuration:
vim /etc/sysconfig/network-scripts/ifcfg-ens33
Add configuration parameters:
BOOTPROTO=static
IPADDR=192.168.88.101
NETMASK=255.255.255.0
GATEWAY=192.168.88.2
DNS1=8.8.8.8
Restart network service:
systemctl restart network
Port Management
Port Fundamentals
Network ports enable specific service communication on a single IP address.
Port Inspection Methods
Using netstat
netstat -tuln
Using nmap
nmap localhost
Network Operations
Connectivity Testing
ping google.com
Resource Downloading
wget http://example.com/file.zip
HTTP Requests
curl -I http://example.com
Time Management
Current Time Display
date
Time Calculations
date -d "+2 hours"
Formatted Time Output
date "+%Y-%m-%d %H:%M:%S"
Timezone Configuration (China Standard Time)
timedatectl set-timezone Asia/Shanghai
Automated Time Synchronization
yum install ntp -y
systemctl enable ntpd
systemctl start ntpd
Manual Time Synchronization
ntpdate pool.ntp.org
Environment Variables
Session-Level Variable Modification
export MY_VAR="value"
System-Wide Variable Configuration
Edit /etc/profile or user-specific profiles (~/.bashrc, ~/.bash_profile).
File Linking
Symbolic Links (Soft Links)
ln -s /path/to/original /path/to/link
Hard Links
ln /path/to/original /path/to/link
File Transfer Operations
Uploading Files
Use SCP, SFTP, or rsync protocols for secure file transfers to remote systems.
Downloading Files
Utilize wget, curl, or SCP for retrieving files from remote sources.