当前位置:首页>Linux>Linux 网络管理速查:ip/ifconfig/Netplan 配置指南

Linux 网络管理速查:ip/ifconfig/Netplan 配置指南

  • 2026-04-16 15:51:07
Linux 网络管理速查:ip/ifconfig/Netplan 配置指南

字数 4465,阅读大约需 23 分钟

网络基础概念

OSI 七层模型

7. 应用层 (HTTP, FTP, SSH, DNS)
6. 表示层 (加密、压缩)
5. 会话层 (建立、管理会话)
4. 传输层 (TCP, UDP)
3. 网络层 (IP, 路由)
2. 数据链路层 (以太网、MAC)
1. 物理层 (网线、光纤)

TCP/IP 四层模型

4. 应用层 (HTTP, FTP, SSH)
3. 传输层 (TCP, UDP)
2. 网络层 (IP, ICMP)
1. 网络接口层 (以太网、Wi-Fi)

常用端口

端口
服务
协议
21
FTP
TCP
22
SSH
TCP
25
SMTP
TCP
53
DNS
UDP/TCP
80
HTTP
TCP
110
POP3
TCP
143
IMAP
TCP
443
HTTPS
TCP
3306
MySQL
TCP
5432
PostgreSQL
TCP
6379
Redis
TCP
8080
HTTP Alt
TCP

网络接口配置

ip 命令(新版)

# 查看网络接口
ip addr
ip a

# 查看特定接口

ip addr show eth0

# 添加 IP 地址

sudo
 ip addr add 192.168.1.100/24 dev eth0

# 删除 IP 地址

sudo
 ip addr del 192.168.1.100/24 dev eth0

# 启用接口

sudo
 ip link set eth0 up

# 禁用接口

sudo
 ip link set eth0 down

# 修改 MAC 地址

sudo
 ip link set dev eth0 address 00:11:22:33:44:55

# 查看路由表

ip route

# 添加默认网关

sudo
 ip route add default via 192.168.1.1

# 添加静态路由

sudo
 ip route add 10.0.0.0/8 via 192.168.1.254

# 删除路由

sudo
 ip route del 10.0.0.0/8

# 查看邻居(ARP 表)

ip neigh

# 清除 ARP 缓存

sudo
 ip neigh flush all

ifconfig 命令(旧版)

# 查看所有接口
ifconfig -a

# 查看特定接口

ifconfig eth0

# 配置 IP 地址

sudo
 ifconfig eth0 192.168.1.100 netmask 255.255.255.0

# 启用/禁用接口

sudo
 ifconfig eth0 up
sudo
 ifconfig eth0 down

# 修改 MAC 地址

sudo
 ifconfig eth0 hw ether 00:11:22:33:44:55

NetworkManager(桌面环境)

# 查看连接
nmcli connection show

# 查看设备

nmcli device status

# 创建连接

sudo
 nmcli connection add type ethernet con-name my-eth ifname eth0 \
    ipv4.addresses 192.168.1.100/24 \
    ipv4.gateway 192.168.1.1 \
    ipv4.dns "8.8.8.8 8.8.4.4" \
    ipv4.method manual

# 修改连接

sudo
 nmcli connection modify my-eth ipv4.addresses 192.168.1.200/24

# 启用连接

sudo
 nmcli connection up my-eth

# 删除连接

sudo
 nmcli connection delete my-eth

# 查看 WiFi

nmcli device wifi list

# 连接 WiFi

sudo
 nmcli device wifi connect "SSID" password "PASSWORD"

配置文件方式

Debian/Ubuntu (/etc/network/interfaces)

# 静态 IP
auto eth0
iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4

# DHCP

auto eth0
iface eth0 inet dhcp

# 应用配置

sudo
 systemctl restart networking
# 或

sudo
 ifdown eth0 && sudo ifup eth0

CentOS/RHEL (/etc/sysconfig/network-scripts/ifcfg-eth0)

# 静态 IP
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4

# DHCP

TYPE=Ethernet
BOOTPROTO=dhcp
NAME=eth0
DEVICE=eth0
ONBOOT=yes

# 应用配置

sudo
 systemctl restart network
# 或

sudo
 ifdown eth0 && sudo ifup eth0

Netplan (Ubuntu 18.04+)

# /etc/netplan/01-netcfg.yaml
network:

  version:
 2
  renderer:
 networkd
  ethernets:

    eth0:

      dhcp4:
 no
      addresses:

        -
 192.168.1.100/24
      gateway4:
 192.168.1.1
      nameservers:

        addresses:
 [8.8.8.8, 8.8.4.4]

# 应用配置

sudo
 netplan apply
# 测试配置

sudo
 netplan try

IP 地址与路由

IP 地址分类

A 类:1.0.0.0 - 126.255.255.255  (默认掩码 255.0.0.0 或 /8)
B 类:128.0.0.0 - 191.255.255.255 (默认掩码 255.255.0.0 或 /16)
C 类:192.0.0.0 - 223.255.255.255 (默认掩码 255.255.255.0 或 /24)

私有地址:
10.0.0.0/8       → 10.0.0.0 - 10.255.255.255
172.16.0.0/12    → 172.16.0.0 - 172.31.255.255
192.168.0.0/16   → 192.168.0.0 - 192.168.255.255
127.0.0.0/8      → 本地回环

子网掩码计算

/24 = 255.255.255.0   = 256 个 IP (254 个可用)
/25 = 255.255.255.128 = 128 个 IP (126 个可用)
/26 = 255.255.255.192 = 64 个 IP (62 个可用)
/27 = 255.255.255.224 = 32 个 IP (30 个可用)
/28 = 255.255.255.240 = 16 个 IP (14 个可用)
/29 = 255.255.255.248 = 8 个 IP (6 个可用)
/30 = 255.255.255.252 = 4 个 IP (2 个可用)

路由配置

# 查看路由表
ip route
route -n
netstat -rn

# 添加默认网关

sudo
 ip route add default via 192.168.1.1
sudo
 route add default gw 192.168.1.1

# 添加静态路由

sudo
 ip route add 10.0.0.0/8 via 192.168.1.254
sudo
 route add -net 10.0.0.0/8 gw 192.168.1.254

# 添加主机路由

sudo
 ip route add 192.168.2.100 via 192.168.1.254

# 删除路由

sudo
 ip route del 10.0.0.0/8

# 测试路由

traceroute 8.8.8.8
tracepath 8.8.8.8
mtr 8.8.8.8

NAT 配置

# 启用 IP 转发
echo
 1 | sudo tee /proc/sys/net/ipv4/ip_forward
# 永久生效

sudo
 tee -a /etc/sysctl.conf << EOF
net.ipv4.ip_forward = 1
EOF

sudo
 sysctl -p

# 配置 NAT(iptables)

sudo
 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo
 iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo
 iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

# 保存规则(CentOS)

sudo
 service iptables save

# 保存规则(Ubuntu)

sudo
 iptables-save > /etc/iptables/rules.v4

DNS 配置

配置文件

# /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com

# 注意:NetworkManager 可能会覆盖此文件

防止覆盖

# Debian/Ubuntu
sudo
 chattr +i /etc/resolv.conf

# 或配置 NetworkManager

sudo
 tee /etc/NetworkManager/NetworkManager.conf << EOF
[main]
dns=none
EOF

sudo
 systemctl restart NetworkManager

# 或使用 systemd-resolved

sudo
 systemctl disable systemd-resolved
sudo
 systemctl stop systemd-resolved

DNS 测试

# 查询 DNS
nslookup google.com
dig google.com

# 指定 DNS 服务器

dig @8.8.8.8 google.com

# 查询 MX 记录

dig mx google.com

# 查询 NS 记录

dig ns google.com

# 反向查询

dig -x 8.8.8.8

# 快速测试

host google.com

本地 DNS 缓存

# 查看 systemd-resolved 缓存
systemd-resolve --statistics

# 清除 DNS 缓存

sudo
 systemd-resolve --flush-caches
# 或

sudo
 resolvectl flush-caches

# 使用 dnsmasq

sudo
 apt install dnsmasq
sudo
 systemctl enable dnsmasq
sudo
 systemctl start dnsmasq

防火墙配置

firewalld(CentOS/RHEL)

# 查看状态
sudo
 systemctl status firewalld

# 启动/停止

sudo
 systemctl start firewalld
sudo
 systemctl stop firewalld
sudo
 systemctl enable firewalld

# 查看区域

firewall-cmd --get-zones
firewall-cmd --get-default-zone

# 查看开放端口

firewall-cmd --list-ports
firewall-cmd --list-services

# 开放端口

sudo
 firewall-cmd --permanent --add-port=80/tcp
sudo
 firewall-cmd --permanent --add-port=443/tcp
sudo
 firewall-cmd --reload

# 开放服务

sudo
 firewall-cmd --permanent --add-service=http
sudo
 firewall-cmd --permanent --add-service=https
sudo
 firewall-cmd --permanent --add-service=ssh
sudo
 firewall-cmd --reload

# 删除端口

sudo
 firewall-cmd --permanent --remove-port=80/tcp
sudo
 firewall-cmd --reload

# 富规则(IP 白名单)

sudo
 firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="ssh" accept'
sudo
 firewall-cmd --reload

# 查看规则

sudo
 firewall-cmd --list-all
sudo
 firewall-cmd --list-all-zones

iptables(通用)

# 查看规则
sudo
 iptables -L -n -v

# 查看 NAT 规则

sudo
 iptables -t nat -L -n -v

# 默认策略

sudo
 iptables -P INPUT DROP
sudo
 iptables -P FORWARD DROP
sudo
 iptables -P OUTPUT ACCEPT

# 允许回环

sudo
 iptables -A INPUT -i lo -j ACCEPT
sudo
 iptables -A OUTPUT -o lo -j ACCEPT

# 允许已建立的连接

sudo
 iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# 允许 SSH

sudo
 iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# 允许 HTTP/HTTPS

sudo
 iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo
 iptables -A INPUT -p tcp --dport 443 -j ACCEPT

# 允许特定 IP

sudo
 iptables -A INPUT -s 192.168.1.100 -j ACCEPT

# 阻止特定 IP

sudo
 iptables -A INPUT -s 10.0.0.100 -j DROP

# 防止 DDoS(限制连接速率)

sudo
 iptables -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT

# 删除规则

sudo
 iptables -D INPUT 1

# 清空规则

sudo
 iptables -F
sudo
 iptables -t nat -F
sudo
 iptables -t mangle -F

# 保存规则

sudo
 iptables-save > /etc/iptables/rules.v4

# 恢复规则

sudo
 iptables-restore < /etc/iptables/rules.v4

ufw(Ubuntu)

# 查看状态
sudo
 ufw status
sudo
 ufw status verbose

# 启用/禁用

sudo
 ufw enable
sudo
 ufw disable

# 默认策略

sudo
 ufw default deny incoming
sudo
 ufw default allow outgoing

# 允许端口

sudo
 ufw allow 22/tcp
sudo
 ufw allow 80/tcp
sudo
 ufw allow 443/tcp

# 允许服务

sudo
 ufw allow ssh
sudo
 ufw allow http
sudo
 ufw allow https

# 允许 IP 范围

sudo
 ufw allow from 192.168.1.0/24

# 允许特定 IP 访问特定端口

sudo
 ufw allow from 192.168.1.100 to any port 22

# 删除规则

sudo
 ufw delete allow 80/tcp

# 重置

sudo
 ufw reset

# 查看日志

sudo
 ufw logging on
sudo
 tail -f /var/log/ufw.log

网络诊断工具

ping(连通性测试)

# 基本 ping
ping google.com

# 指定次数

ping -c 4 google.com

# 指定间隔

ping -i 2 google.com

# 指定包大小

ping -s 1000 google.com

# 快速 ping

ping -f google.com

# 带时间戳

ping -D google.com

traceroute(路由跟踪)

# 基本跟踪
traceroute google.com

# 使用 ICMP

traceroute -I google.com

# 使用 TCP

traceroute -T google.com

# 指定端口

traceroute -T -p 443 google.com

# 替代工具

tracepath google.com
mtr google.com  # 结合 ping 和 traceroute

netstat/ss(网络连接)

# 查看所有连接
netstat -an
ss -an

# 查看监听端口

netstat -tulpn
ss -tulpn

# 查看 TCP 连接

netstat -at
ss -t

# 查看 UDP 连接

netstat -au
ss -u

# 查看统计信息

netstat -s
ss -s

# 查看进程

netstat -tulpn
ss -tulpn

# 持续监控

watch -n 1 'ss -t'

tcpdump(抓包)

# 抓取所有流量
sudo
 tcpdump -i any

# 抓取特定接口

sudo
 tcpdump -i eth0

# 抓取指定数量

sudo
 tcpdump -i eth0 -c 100

# 保存为文件

sudo
 tcpdump -i eth0 -w capture.pcap

# 读取文件

tcpdump -r capture.pcap

# 过滤端口

sudo
 tcpdump -i eth0 port 80
sudo
 tcpdump -i eth0 port 22

# 过滤 IP

sudo
 tcpdump -i eth0 host 192.168.1.100
sudo
 tcpdump -i eth0 src 192.168.1.100
sudo
 tcpdump -i eth0 dst 192.168.1.100

# 过滤协议

sudo
 tcpdump -i eth0 tcp
sudo
 tcpdump -i eth0 udp
sudo
 tcpdump -i eth0 icmp

# 详细输出

sudo
 tcpdump -i eth0 -vv
sudo
 tcpdump -i eth0 -vvv

# 十六进制输出

sudo
 tcpdump -i eth0 -xx

curl(HTTP 测试)

# 基本请求
curl https://example.com

# 显示响应头

curl -I https://example.com

# 显示详细过程

curl -v https://example.com

# 下载文件

curl -O https://example.com/file.zip
curl -o myfile.zip https://example.com/file.zip

# 发送 POST

curl -X POST -d "key=value" https://example.com

# 发送 JSON

curl -X POST -H "Content-Type: application/json" \
     -d '{"key":"value"}' https://example.com

# 认证

curl -u username:password https://example.com

# 忽略证书错误

curl -k https://example.com

# 限速

curl --limit-rate 100k https://example.com/file.zip

# 重试

curl --retry 3 https://example.com

wget(下载工具)

# 下载文件
wget https://example.com/file.zip

# 指定输出文件名

wget -O myfile.zip https://example.com/file.zip

# 断点续传

wget -c https://example.com/file.zip

# 后台下载

wget -b https://example.com/file.zip

# 递归下载

wget -r https://example.com/dir/

# 限制速率

wget --limit-rate=100k https://example.com/file.zip

# 指定 User-Agent

wget --user-agent="Mozilla/5.0" https://example.com

SSH 配置与安全

SSH 基本配置

# 连接 SSH
ssh user@host

# 指定端口

ssh -p 2222 user@host

# 指定密钥

ssh -i ~/.ssh/id_rsa user@host

# 启用 X11 转发

ssh -X user@host

# 端口转发(本地)

ssh -L 8080:localhost:80 user@host

# 端口转发(远程)

ssh -R 8080:localhost:80 user@host

# SOCKS 代理

ssh -D 1080 user@host

# 执行远程命令

ssh user@host "ls -la"

# 复制文件(SCP)

scp file.txt user@host:/path/
scp -r dir/ user@host:/path/

# 复制文件(SFTP)

sftp user@host

SSH 服务端配置

# /etc/ssh/sshd_config

# 基本配置

Port 22
#Port 2222                    # 修改端口
ListenAddress 0.0.0.0

# 认证

PermitRootLogin no           # 禁止 root 登录
PasswordAuthentication yes   # 密码认证
PubkeyAuthentication yes     # 密钥认证
PermitEmptyPasswords no      # 禁止空密码

# 安全

Protocol 2                   # 只允许 SSHv2
X11Forwarding no             # 禁用 X11 转发
MaxAuthTries 3               # 最大认证次数
ClientAliveInterval 300      # 心跳间隔
ClientAliveCountMax 2        # 心跳超时次数

# 用户限制

AllowUsers longge admin      # 允许的用户
#DenyUsers root               # 禁止的用户

AllowGroups sshusers         # 允许的组

# 日志

LogLevel INFO

# 重启服务

sudo
 systemctl restart sshd

SSH 密钥管理

# 生成密钥
ssh-keygen -t ed25519
ssh-keygen -t rsa -b 4096

# 复制公钥到服务器

ssh-copy-id user@host

# 手动复制

cat
 ~/.ssh/id_rsa.pub | ssh user@host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

# 查看密钥指纹

ssh-keygen -lf ~/.ssh/id_rsa.pub

# 生成密钥注释

ssh-keygen -l -f ~/.ssh/id_rsa.pub

# 删除密钥

ssh-keygen -R host

# 测试密钥

ssh -i ~/.ssh/id_rsa user@host

SSH 安全加固

# 1. 禁用密码认证,只用密钥
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no

# 2. 修改默认端口

Port 2222

# 3. 限制用户

AllowUsers longge

# 4. 使用 Fail2ban

sudo
 apt install fail2ban
sudo
 systemctl enable fail2ban
sudo
 systemctl start fail2ban

# 5. 配置 Fail2ban

sudo
 tee /etc/fail2ban/jail.local << EOF
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 3600
EOF


sudo
 systemctl restart fail2ban

# 6. 双因素认证(Google Authenticator)

sudo
 apt install libpam-google-authenticator
google-authenticator
# 编辑 /etc/pam.d/sshd 添加:

# auth required pam_google_authenticator.so

SSH 隧道

# 本地端口转发
# 访问本地 8080 → 远程服务器的 localhost:80

ssh -L 8080:localhost:80 user@remote

# 远程端口转发

# 访问远程服务器的 8080 → 本地的 localhost:80

ssh -R 8080:localhost:80 user@remote

# 动态端口转发(SOCKS 代理)

ssh -D 1080 user@remote
# 浏览器配置 SOCKS 代理 localhost:1080


# 持久化隧道(autossh)

sudo
 apt install autossh
autossh -M 0 -f -N -L 8080:localhost:80 user@remote

网络服务

Nginx 配置

# 安装
sudo
 apt install nginx
sudo
 yum install nginx

# 基本配置

sudo
 tee /etc/nginx/sites-available/example << EOF
server {
    listen 80;
    server_name example.com;
    root /var/www/example;
    index index.html;

    location / {
        try_files \$uri \$uri/ =404;
    }

    location /api/ {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
    }
}
EOF


# 启用站点

sudo
 ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/

# 测试配置

sudo
 nginx -t

# 重启服务

sudo
 systemctl restart nginx

HAProxy 配置

# 安装
sudo
 apt install haproxy

# 基本配置

sudo
 tee /etc/haproxy/haproxy.cfg << EOF
global
    log /dev/log local0
    maxconn 4096

defaults
    log global
    mode http
    option httplog
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http_front
    bind *:80
    default_backend http_back

backend http_back
    balance roundrobin
    server web1 192.168.1.10:80 check
    server web2 192.168.1.11:80 check
    server web3 192.168.1.12:80 check
EOF


# 重启服务

sudo
 systemctl restart haproxy

DHCP 服务器

# 安装
sudo
 apt install isc-dhcp-server

# 配置

sudo
 tee /etc/dhcp/dhcpd.conf << EOF
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    option domain-name "example.com";
    default-lease-time 600;
    max-lease-time 7200;
}
EOF


# 启动服务

sudo
 systemctl start isc-dhcp-server

实战案例

案例 1:配置双网卡路由

# 场景:内网 eth0 (192.168.1.x),外网 eth1 (10.0.0.x)

# 1. 配置内网

sudo
 ip addr add 192.168.1.100/24 dev eth0
sudo
 ip link set eth0 up

# 2. 配置外网

sudo
 ip addr add 10.0.0.100/24 dev eth1
sudo
 ip link set eth1 up
sudo
 ip route add default via 10.0.0.1 dev eth1

# 3. 添加内网路由

sudo
 ip route add 192.168.0.0/16 via 192.168.1.1 dev eth0

# 4. 配置 NAT(让内网通过外网上网)

echo
 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo
 iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
sudo
 iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
sudo
 iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT

# 5. 持久化配置

# 编辑 /etc/network/interfaces 或使用 netplan

案例 2:搭建 VPN 服务器(WireGuard)

# 1. 安装 WireGuard
sudo
 apt install wireguard

# 2. 生成密钥

cd
 /etc/wireguard
wg genkey | tee privatekey | wg pubkey > publickey

# 3. 服务器配置

sudo
 tee /etc/wireguard/wg0.conf << EOF
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = $(cat privatekey)
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
# Client 1
PublicKey = CLIENT_PUBLIC_KEY
AllowedIPs = 10.0.0.2/32

[Peer]
# Client 2
PublicKey = CLIENT2_PUBLIC_KEY
AllowedIPs = 10.0.0.3/32
EOF


# 4. 启动服务

sudo
 wg-quick up wg0
sudo
 systemctl enable wg-quick@wg0

# 5. 客户端配置

[Interface]
Address = 10.0.0.2/24
PrivateKey = CLIENT_PRIVATE_KEY
DNS = 8.8.8.8

[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = SERVER_IP:51820
AllowedIPs = 0.0.0.0/0

# 6. 查看状态

wg show

案例 3:配置负载均衡

# 使用 Nginx 作为负载均衡器

sudo
 tee /etc/nginx/nginx.conf << EOF
user www-data;
worker_processes auto;

events {
    worker_connections 1024;
}

http {
    upstream backend {
        least_conn;
        server 192.168.1.10:80 weight=3;
        server 192.168.1.11:80 weight=2;
        server 192.168.1.12:80 weight=1;
        keepalive 32;
    }

    server {
        listen 80;
        server_name example.com;

        location / {
            proxy_pass http://backend;
            proxy_set_header Host \$host;
            proxy_set_header X-Real-IP \$remote_addr;
            proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
            proxy_connect_timeout 5s;
            proxy_read_timeout 30s;
        }

        location /health {
            access_log off;
            return 200 "healthy\n";
        }
    }
}
EOF


sudo
 nginx -t
sudo
 systemctl restart nginx

案例 4:网络监控脚本

#!/bin/bash
# network-monitor.sh


LOG_FILE="/var/log/network-monitor.log"
ALERT_EMAIL="admin@example.com"

log
() {
    echo
 "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a $LOG_FILE
}

# 检查外网连通性

check_internet
() {
    if
 ! ping -c 3 8.8.8.8 > /dev/null 2>&1; then
        log
 "ERROR: Internet connection lost!"
        # 可以添加告警逻辑

        return
 1
    fi

    log
 "OK: Internet connection is fine"
    return
 0
}

# 检查端口

check_port
() {
    local
 host=$1
    local
 port=$2
    if
 ! nc -z -w 3 $host $port > /dev/null 2>&1; then
        log
 "ERROR: $host:$port is not accessible"
        return
 1
    fi

    log
 "OK: $host:$port is accessible"
    return
 0
}

# 检查带宽

check_bandwidth
() {
    local
 iface=${1:-eth0}
    local
 rx_before=$(cat /sys/class/net/$iface/statistics/rx_bytes)
    local
 tx_before=$(cat /sys/class/net/$iface/statistics/tx_bytes)
    sleep
 1
    local
 rx_after=$(cat /sys/class/net/$iface/statistics/rx_bytes)
    local
 tx_after=$(cat /sys/class/net/$iface/statistics/tx_bytes)

    local
 rx_rate=$(( (rx_after - rx_before) / 1024 ))
    local
 tx_rate=$(( (tx_after - tx_before) / 1024 ))

    log
 "Bandwidth $iface: RX=${rx_rate}KB/s TX=${tx_rate}KB/s"
}

# 检查连接数

check_connections
() {
    local
 count=$(ss -t | wc -l)
    log
 "TCP connections: $count"
    if
 [ $count -gt 1000 ]; then
        log
 "WARNING: High number of connections!"
    fi

}

# 主循环

main
() {
    log
 "=== Network Monitor Started ==="
    while
 true; do
        check_internet
        check_port localhost 22
        check_port localhost 80
        check_bandwidth eth0
        check_connections
        sleep
 60
    done

}

main

案例 5:网络故障排查流程

#!/bin/bash
# network-troubleshoot.sh


echo
 "=== Network Troubleshooting Script ==="
echo


# 1. 检查网络接口

echo
 "1. Network Interfaces:"
ip addr show | grep -E "^[0-9]+:|inet "
echo


# 2. 检查路由

echo
 "2. Routing Table:"
ip route show
echo


# 3. 检查 DNS

echo
 "3. DNS Configuration:"
cat
 /etc/resolv.conf
echo


# 4. 测试网关

echo
 "4. Testing Gateway:"
GATEWAY=$(ip route | grep default | awk '{print $3}')
if
 [ -n "$GATEWAY" ]; then
    ping -c 3 $GATEWAY
else

    echo
 "No default gateway found!"
fi

echo


# 5. 测试外网

echo
 "5. Testing Internet:"
ping -c 3 8.8.8.8
echo


# 6. 测试 DNS 解析

echo
 "6. Testing DNS Resolution:"
nslookup google.com
echo


# 7. 检查防火墙

echo
 "7. Firewall Status:"
if
 command -v ufw &> /dev/null; then
    sudo
 ufw status
elif
 command -v firewall-cmd &> /dev/null; then
    sudo
 firewall-cmd --list-all
elif
 command -v iptables &> /dev/null; then
    sudo
 iptables -L -n | head -20
fi

echo


# 8. 检查监听端口

echo
 "8. Listening Ports:"
ss -tulpn | head -20
echo


# 9. 检查网络连接

echo
 "9. Active Connections:"
ss -t | head -20
echo


echo
 "=== Troubleshooting Complete ==="

避坑指南

坑 1:配置错误导致失联

# ❌ 错误:远程修改防火墙规则
sudo
 ufw default deny incoming
# 结果:把自己锁在外面


# ✅ 正确:先允许 SSH

sudo
 ufw allow 22/tcp
sudo
 ufw enable

# 或使用定时任务恢复

(crontab -l 2>/dev/null; echo "@reboot /usr/sbin/ufw disable") | crontab -
# 测试成功后删除

坑 2:DNS 配置被覆盖

# ❌ 错误:直接修改 /etc/resolv.conf
# 结果:重启后被 NetworkManager 覆盖


# ✅ 正确:修改 NetworkManager 配置

sudo
 tee /etc/NetworkManager/NetworkManager.conf << EOF
[main]
dns=none
EOF

sudo
 systemctl restart NetworkManager

# 然后修改 /etc/resolv.conf

坑 3:NAT 规则丢失

# ❌ 错误:重启后 NAT 规则消失
sudo
 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# ✅ 正确:保存规则

sudo
 iptables-save > /etc/iptables/rules.v4

# 或配置开机加载

sudo
 tee /etc/network/if-pre-up.d/iptables << EOF
#!/bin/sh
iptables-restore < /etc/iptables/rules.v4
EOF

sudo
 chmod +x /etc/network/if-pre-up.d/iptables

坑 4:SSH 密钥权限错误

# ❌ 错误:权限太开放
chmod
 777 ~/.ssh/authorized_keys
# 结果:SSH 拒绝使用


# ✅ 正确:设置正确权限

chmod
 700 ~/.ssh
chmod
 600 ~/.ssh/authorized_keys
chmod
 600 ~/.ssh/id_rsa
chmod
 644 ~/.ssh/id_rsa.pub

坑 5:MTU 问题导致网络慢

# ❌ 错误:忽略 MTU 设置
# 结果:大包被丢弃,网络慢


# ✅ 正确:检查并设置 MTU

ip link show
# 如果看到需要分片,降低 MTU

sudo
 ip link set dev eth0 mtu 1400

# 永久设置(/etc/network/interfaces)

mtu 1400

练习题

基础题

  1. 1. 查看当前 IP 地址和路由表
  2. 2. ping 测试外网连通性
  3. 3. 查看开放的端口
  4. 4. 测试 DNS 解析

进阶题

  1. 5. 配置静态 IP 地址
  2. 6. 配置防火墙允许 HTTP/HTTPS/SSH
  3. 7. 配置 SSH 密钥登录
  4. 8. 创建网络监控脚本

答案

# 1
ip addr
ip route

# 2

ping -c 4 8.8.8.8

# 3

ss -tulpn

# 4

nslookup google.com
# 或

dig google.com

# 5

# 见 Netplan 配置章节


# 6

sudo
 ufw allow 22/tcp
sudo
 ufw allow 80/tcp
sudo
 ufw allow 443/tcp
sudo
 ufw enable

# 7

ssh-keygen -t ed25519
ssh-copy-id user@host

# 8

# 见案例 4

📊 命令速查表

功能
命令
查看 IP
ip addr
 / ifconfig
查看路由
ip route
 / route -n
查看连接
ss -tulpn
 / netstat -tulpn
测试连通
ping host
路由跟踪
traceroute host
DNS 查询
dig domain
 / nslookup domain
抓包
tcpdump -i eth0
HTTP 测试
curl url
 / wget url
防火墙
ufw
 / firewall-cmd / iptables
SSH 连接
ssh user@host
文件传输
scp file user@host:/path
端口转发
ssh -L 8080:localhost:80 user@host

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-04-16 21:00:25 HTTP/2.0 GET : https://f.mffb.com.cn/a/485618.html
  2. 运行时间 : 0.109258s [ 吞吐率:9.15req/s ] 内存消耗:4,912.59kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=c8f27a4820c886b990c6e02a7c3a848b
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000706s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000980s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000337s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000324s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000841s ]
  6. SELECT * FROM `set` [ RunTime:0.000389s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000906s ]
  8. SELECT * FROM `article` WHERE `id` = 485618 LIMIT 1 [ RunTime:0.000628s ]
  9. UPDATE `article` SET `lasttime` = 1776344425 WHERE `id` = 485618 [ RunTime:0.001375s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.000334s ]
  11. SELECT * FROM `article` WHERE `id` < 485618 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000624s ]
  12. SELECT * FROM `article` WHERE `id` > 485618 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.002585s ]
  13. SELECT * FROM `article` WHERE `id` < 485618 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001511s ]
  14. SELECT * FROM `article` WHERE `id` < 485618 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.007854s ]
  15. SELECT * FROM `article` WHERE `id` < 485618 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001583s ]
0.111037s