1·配置路由表

  • 默认路由

    ip -4 route
    ip -6 route
  • 测试网关连通性

    ping4 xx.xx.xx.xx
    ping6 xx.xx.xx.xx.xx.xx
  • 修改默认路由

    sudo ip -4 route del default via xx.xx.xx.xx
    sudo ip -4 route add default via xx.xx.xx.xx
    sudo ip -6 route del default via xx.xx.xx.xx.xx.xx
    sudo ip -6 route add default via xx.xx.xx.xx.xx.xx
    ip -4 route
    ip -6 route

    注意:路由可在vps面板查找

2·网络接口配置

  • 修改配置文件

    cd /etc/network
    cd /etc/network/interfaces.d
  • 标准配置

    # This file is generated from information provided by the datasource.  Changes
    # to it will not persist across an instance reboot.  To disable cloud-init's
    # network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/xxxx.cfg with the following:
    # network: {config: disabled}
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
      #address xx.xx.xx.xx
      address xx.xx.xx.xx/23
    
      #子网掩码
      netmask 255.255.255.0
    
      #dns-nameservers xx.xx.xx.xx xx.xx.xx.xx
      dns-nameservers 1.1.1.1
    
      #网关ipv4
      gateway xx.xx.xx.xx
    
    # control-alias eth0
    iface eth0 inet6 static
      #address xx.xx.xx.xx.xx.xx
      address xx.xx.xx.xx.xx.xx/48
    
      #子网掩码
      netmask 64
    
      #dns-nameservers xx.xx.xx.xx xx.xx xx.xx.xx.xx xx.xx
    
      #网关ipv6
      gateway xx.xx.xx.xx.xx.xx
  • 重启网络服务

    systemctl restart networking