Skip to content

获取内网IP

如果希望在同一个算力区域的两台机器之间传输数据,使用内网IP进行连接速度要更快。

首先确认实例所在的算力区域: alt text

使用ifconfig命令可以让你看到容器的网络配置。

bash
# 安装工具
apt update
apt install net-tools
# 查看网络
ifconfig
# 结果
"""
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1480
        inet 100.114.234.198  netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 fe80::1437:68ff:fea9:5c9d  prefixlen 64  scopeid 0x20<link>
        ether 16:37:68:a9:5c:9d  txqueuelen 0  (Ethernet)
        RX packets 11182  bytes 43024122 (43.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7630  bytes 7500984 (7.5 MB)
        TX errors 0  dropped 1 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
"""

etc0表示实例虚拟网卡,对应IP为第二行的inet,如示例中为100.114.234.198

然后在内网中,使用ssh root@100.114.234.198进行连接。其他命令,如scp或者rsync,也可以使用内网IP进行连接。