• 22-10-2024, 12:22:36
    #1
    Platin üye
    clodfare toplu ip değiştirme işini bilmiyorum.
    Bu konuyu bilen birisi bana anydesk ile bağlanıp bu işi öğretebilir mi
    ücretli - ücretsiz tüm tekliflere açığım

    skype: https://join.skype.com/invite/IGXGQum11nVd
    watsap: https://wa.me/5350579988
  • 22-10-2024, 12:29:34
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
    CF API ile mümkün.

    import requests
    
    def update_dns_record(zone_id, record_id, new_ip, api_token):
        url = f"https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records/{record_id}"
        headers = {
            "Authorization": f"Bearer {api_token}",
            "Content-Type": "application/json"
        }
        data = {
            "type": "A",  # IPv4 için A kaydı, IPv6 için AAAA kaydı kullanılır.
            "name": "example.com",
            "content": new_ip,
            "ttl": 1,
            "proxied": False  # Cloudflare proxysi kullanılıp kullanılmayacağına bağlı olarak True/False ayarlayın.
        }
        
        response = requests.put(url, headers=headers, json=data)
        
        if response.status_code == 200:
            print(f"DNS kaydı güncellendi: {response.json()}")
        else:
            print(f"Bir hata oluştu: {response.status_code}, {response.text}")
    
    # Örnek kullanım
    update_dns_record("ZONE_ID", "RECORD_ID", "NEW_IP_ADDRESS", "API_TOKEN")
  • 22-10-2024, 12:34:51
    #3
    Mubido & FatBotter
    Cloudflare api ile yapmak için, hesabınızda ekli olan sitelerin zone id'lerine ihtiyacınız olacak.

    Buyrun tüm bu işlemleri yapan bir php sınıf. Bir php dosyası oluşturup içine bu kodu yapıştırın ve kullanım örneğindeki verileri kendinize göre ayarlayın.

    class CloudflareDNSUpdater {
    private $apiKey;
    private $email;
    private $newIP;
    private $baseURL = 'https://api.cloudflare.com/client/v4/';
    
    public function __construct($apiKey, $email, $newIP) {
    $this->apiKey = $apiKey;
    $this->email = $email;
    $this->newIP = $newIP;
    }
    
    private function makeRequest($endpoint, $method = 'GET', $data = null) {
    $ch = curl_init($this->baseURL . $endpoint);
    
    $headers = [
    'X-Auth-Email: ' . $this->email,
    'X-Auth-Key: ' . $this->apiKey,
    'Content-Type: application/json'
            ];
    
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    if ($method === 'PUT' || $method === 'PATCH') {
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    if ($data) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    }
    }
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    return [
    'code' => $httpCode,
    'data' => json_decode($response, true)
    ];
    }
    
    public function getAllZones() {
    $response = $this->makeRequest('zones');
    if ($response['code'] === 200) {
    return $response['data']['result'];
    }
    return null;
    }
    
    public function getDNSRecords($zoneId) {
    $response = $this->makeRequest("zones/{$zoneId}/dns_records");
    if ($response['code'] === 200) {
    return $response['data']['result'];
    }
    return null;
    }
    
    public function updateDNSRecord($zoneId, $recordId, $recordData) {
    $data = array_merge($recordData, ['content' => $this->newIP]);
    return $this->makeRequest("zones/{$zoneId}/dns_records/{$recordId}", 'PATCH', $data);
    }
    
    public function updateAllARecords() {
    $zones = $this->getAllZones();
    if (!$zones) {
    echo "Zoneler alınamadı!\n";
    return false;
    }
    
    foreach ($zones as $zone) {
    echo "İşleniyor: {$zone['name']}\n";
    
    $dnsRecords = $this->getDNSRecords($zone['id']);
    if (!$dnsRecords) {
    echo "- DNS kayıtları alınamadı!\n";
    continue;
    }
    
    foreach ($dnsRecords as $record) {
    if ($record['type'] === 'A') {
    $updateData = [
    'type' => 'A',
    'name' => $record['name'],
    'proxied' => $record['proxied'],
    'ttl' => $record['ttl']
    ];
    
    $response = $this->updateDNSRecord($zone['id'], $record['id'], $updateData);
    
    if ($response['code'] === 200) {
    echo "- {$record['name']} güncellendi: {$this->newIP}\n";
    } else {
    echo "- {$record['name']} güncellenemedi!\n";
    }
    }
    }
    }
    return true;
    }
    }
    
    // Kullanım örneği:
    $apiKey = 'YOUR_API_KEY';
    $email = 'YOUR_EMAIL';
    $newIP = 'NEW_IP_ADDRESS';
    
    $updater = new CloudflareDNSUpdater($apiKey, $email, $newIP);
    $updater->updateAllARecords();