我的Ubuntu虚拟机使用的是桥接模式,现在似乎被深信服网罗管理拦截了。平常新的设备加入网络需要跳转到1.1.1.3:80进行用户名和密码认证。看更新系统时间的命令返回的命令,

minghui@mhubuntu21047:~$ sudo apt install ntpdate      # 安装时间同步工具
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ntpsec-ntpdate ntpsec-ntpdig python3-ntp
The following NEW packages will be installed:
  ntpdate ntpsec-ntpdate ntpsec-ntpdig python3-ntp
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 156 kB of archives.
After this operation, 607 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu noble/universe amd64 python3-ntp amd64 1.2.2+dfsg1-4build2 [91.2 kB]
Err:1 http://archive.ubuntu.com/ubuntu noble/universe amd64 python3-ntp amd64 1.2.2+dfsg1-4build2
  File has unexpected size (2250 != 91242). Mirror sync in progress? [IP: 1.1.1.3 80]
  Hashes of expected file:
   - SHA512:a8db57074716cbd66eee628c17d72c52cb17c8fcd352a3fbe018f452617866bb26d1256a5101ddfd40efffb706f38728a44534b1b9704694700a6822735aa9df
   - SHA256:f0e00b8bdc4b8fe6a9546b36ce8af9ab07aa09d97823cbdc1c7a221de5b8fb5e
   - SHA1:5ae78b5b8f1def038896c4f9c94f956f0910b1b6 [weak]
   - MD5Sum:d8c0a60e1b6733aa76cb5602a16d3727 [weak]
   - Filesize:91242 [weak]
Get:2 http://archive.ubuntu.com/ubuntu noble/universe amd64 ntpsec-ntpdig amd64 1.2.2+dfsg1-4build2 [25.2 kB]
Err:2 http://archive.ubuntu.com/ubuntu noble/universe amd64 ntpsec-ntpdig amd64 1.2.2+dfsg1-4build2
  File has unexpected size (2250 != 25202). Mirror sync in progress? [IP: 1.1.1.3 80]
  Hashes of expected file:
   - SHA512:ac643769f339ce4912685f7c5a058b72b4744fee0bd543f523e04840f4215b5135ef20608e4a284bd9007e4482d434e4a70d08455d0ee939a4111b50c6c4216e
   - SHA256:093c4cd66a9d284ed4846580b8f7d03e57b2f54181e914d44490ee05c1d0f5e1
   - SHA1:faf7bffdab2089f24942d8e7a9dcf608ad51be57 [weak]
   - MD5Sum:0bf9b15352e6e873aa164df1782d54f4 [weak]
   - Filesize:25202 [weak]
Get:3 http://archive.ubuntu.com/ubuntu noble/universe amd64 ntpsec-ntpdate amd64 1.2.2+dfsg1-4build2 [22.3 kB]
Err:3 http://archive.ubuntu.com/ubuntu noble/universe amd64 ntpsec-ntpdate amd64 1.2.2+dfsg1-4build2
  File has unexpected size (2250 != 22324). Mirror sync in progress? [IP: 1.1.1.3 80]
  Hashes of expected file:
   - SHA512:f1a1a2eb9aa5f03eee900527522f5fb0b2dc84e61f4276d637b788d084f822ff5d86acd335cbcca2024482c7814d8d4126225d39aebbc04c1182ac0751d68922
   - SHA256:5102e408bd118dece843a0de5d26fed30e3d003a92a9c1648f2723e672b632cc
   - SHA1:2ab4a1bf67c6f00de2faf7632e54c4c9c9b68ddc [weak]
   - MD5Sum:b8fa548f878e65469e46263eafc24c17 [weak]
   - Filesize:22324 [weak]
Get:4 http://archive.ubuntu.com/ubuntu noble/universe amd64 ntpdate all 1:4.2.8p15+dfsg-2~1.2.2+dfsg1-4build2 [17.5 kB]
Err:4 http://archive.ubuntu.com/ubuntu noble/universe amd64 ntpdate all 1:4.2.8p15+dfsg-2~1.2.2+dfsg1-4build2
  File has unexpected size (2250 != 17534). Mirror sync in progress? [IP: 1.1.1.3 80]
  Hashes of expected file:
   - SHA512:47549f5396e49a599132945a171d0c815b4ee1255ee2972b2efb61d54cede7c5e52c13ed3f6f2dd08de2faea5b943a9c11f5ec37c891ad6396512a21bc11a6fe
   - SHA256:f42f53c3a0be1f115ad325a5d70e96016cd80ea0582f1a24c4df3943578e4ba3
   - SHA1:fd03475d3f8ae0a8b774c4ff846b0d925ebe0b94 [weak]
   - MD5Sum:4335a32df32c18f9e2259577b1767e6a [weak]
   - Filesize:17534 [weak]
E: Failed to fetch http://1.1.1.3:80/ac_portal/proxy.html?ip=192.168.210.47&r=12&t=1744027993&c=20928335916&_FLAG=1&domain_wechat=oauthservice.net&template=default&tabs=pwd-qrcode&vlanid=0&url=http://archive.ubuntu.com%2fubuntu%2fpool%2funiverse%2fn%2fntpsec%2fpython3-ntp_1.2.2%252bdfsg1-4build2_amd64.deb&qrcsrv=355509532  File has unexpected size (2250 != 91242). Mirror sync in progress? [IP: 1.1.1.3 80]
   Hashes of expected file:
    - SHA512:a8db57074716cbd66eee628c17d72c52cb17c8fcd352a3fbe018f452617866bb26d1256a5101ddfd40efffb706f38728a44534b1b9704694700a6822735aa9df
    - SHA256:f0e00b8bdc4b8fe6a9546b36ce8af9ab07aa09d97823cbdc1c7a221de5b8fb5e
    - SHA1:5ae78b5b8f1def038896c4f9c94f956f0910b1b6 [weak]
    - MD5Sum:d8c0a60e1b6733aa76cb5602a16d3727 [weak]
    - Filesize:91242 [weak]
E: Failed to fetch http://1.1.1.3:80/ac_portal/proxy.html?ip=192.168.210.47&r=12&t=1744027993&c=20928335916&_FLAG=1&domain_wechat=oauthservice.net&template=default&tabs=pwd-qrcode&vlanid=0&url=http://archive.ubuntu.com%2fubuntu%2fpool%2funiverse%2fn%2fntpsec%2fntpsec-ntpdig_1.2.2%252bdfsg1-4build2_amd64.deb&qrcsrv=355509532  File has unexpected size (2250 != 25202). Mirror sync in progress? [IP: 1.1.1.3 80]
   Hashes of expected file:
    - SHA512:ac643769f339ce4912685f7c5a058b72b4744fee0bd543f523e04840f4215b5135ef20608e4a284bd9007e4482d434e4a70d08455d0ee939a4111b50c6c4216e
    - SHA256:093c4cd66a9d284ed4846580b8f7d03e57b2f54181e914d44490ee05c1d0f5e1
    - SHA1:faf7bffdab2089f24942d8e7a9dcf608ad51be57 [weak]
    - MD5Sum:0bf9b15352e6e873aa164df1782d54f4 [weak]
    - Filesize:25202 [weak]
E: Failed to fetch http://1.1.1.3:80/ac_portal/proxy.html?ip=192.168.210.47&r=12&t=1744027993&c=20928335916&_FLAG=1&domain_wechat=oauthservice.net&template=default&tabs=pwd-qrcode&vlanid=0&url=http://archive.ubuntu.com%2fubuntu%2fpool%2funiverse%2fn%2fntpsec%2fntpsec-ntpdate_1.2.2%252bdfsg1-4build2_amd64.deb&qrcsrv=355509532  File has unexpected size (2250 != 22324). Mirror sync in progress? [IP: 1.1.1.3 80]
   Hashes of expected file:
    - SHA512:f1a1a2eb9aa5f03eee900527522f5fb0b2dc84e61f4276d637b788d084f822ff5d86acd335cbcca2024482c7814d8d4126225d39aebbc04c1182ac0751d68922
    - SHA256:5102e408bd118dece843a0de5d26fed30e3d003a92a9c1648f2723e672b632cc
    - SHA1:2ab4a1bf67c6f00de2faf7632e54c4c9c9b68ddc [weak]
    - MD5Sum:b8fa548f878e65469e46263eafc24c17 [weak]
    - Filesize:22324 [weak]
E: Failed to fetch http://1.1.1.3:80/ac_portal/proxy.html?ip=192.168.210.47&r=12&t=1744027993&c=20928335916&_FLAG=1&domain_wechat=oauthservice.net&template=default&tabs=pwd-qrcode&vlanid=0&url=http://archive.ubuntu.com%2fubuntu%2fpool%2funiverse%2fn%2fntpsec%2fntpdate_4.2.8p15%252bdfsg-2%257e1.2.2%252bdfsg1-4build2_all.deb&qrcsrv=355509532  File has unexpected size (2250 != 17534). Mirror sync in progress? [IP: 1.1.1.3 80]
   Hashes of expected file:
    - SHA512:47549f5396e49a599132945a171d0c815b4ee1255ee2972b2efb61d54cede7c5e52c13ed3f6f2dd08de2faea5b943a9c11f5ec37c891ad6396512a21bc11a6fe
    - SHA256:f42f53c3a0be1f115ad325a5d70e96016cd80ea0582f1a24c4df3943578e4ba3
    - SHA1:fd03475d3f8ae0a8b774c4ff846b0d925ebe0b94 [weak]
    - MD5Sum:4335a32df32c18f9e2259577b1767e6a [weak]
    - Filesize:17534 [weak]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
minghui@mhubuntu21047:~$ sudo ntpdate pool.ntp.org     # 同步时间
sudo: ntpdate: command not found

执行apt install ntpdate时出现错误,提示文件大小不符,这可能是因为网络请求被防火墙重定向到了认证页面。用户需要先完成网络认证才能继续操作。

平常新设备都在浏览器中访问这个地址进行认证。但我现在使用的是虚拟机,Ubuntu服务版,只有命令行界面,那就需要通过curl命令提交认证信息。

现在尝试用命令行工具如curl或wget来提交认证请求。例如,使用curl发送POST请求到认证接口,带上用户名和密码的表单数据。但需要确认认证接口的具体URL和参数格式。用户提供的信息中,认证地址是1.1.1.3:80,可能需要构造正确的请求。(这个在获取自建的图床链接时也用到)

现在用命令行工具发送认证请求。如果认证成功,网络访问应该恢复,之后才能正常安装软件包和同步时间。

使用 curl 命令行认证

如果虚拟机没有图形界面,可以通过 curl 发送 POST 请求模拟认证(需根据实际认证接口调整参数):

# 尝试发送认证请求(可能需要调整参数)
curl -X POST "http://1.1.1.3/ac_portal/login.php" \
     -d "opr=pwdLogin&userName=username&pwd=123456&rememberPwd=0"

验证网络连通性

认证成功后,测试网络是否正常:

ping 8.8.8.8      # 测试基础网络连通性
curl -I http://example.com  # 测试 HTTP 访问

修复 APT 软件源问题

如果步骤 1 完成但 apt install 仍然失败,可能是 DNS 或软件源配置问题:

1. 检查 DNS 解析

cat /etc/resolv.conf  # 确认 DNS 服务器是否正常(如 8.8.8.8)
ping archive.ubuntu.com  # 测试域名解析

2. 更换软件源镜像

如果 archive.ubuntu.com 被拦截,尝试更换为国内镜像源(如阿里云):

sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
sudo apt update

重新安装所需工具

网络恢复后,安装 ntpdate 并同步时间:

sudo apt install -y ntpdate
sudo ntpdate pool.ntp.org

配置自动时间同步(可选)

sudo apt install -y systemd-timesyncd
sudo timedatectl set-ntp true