Komut
setDNS()
Açıklama
WiFi .setDNS()
, DNS (Etki Alanı Adı Sistemi) sunucusunu yapılandırmanıza olanak tanır.
Sözdizimi
Kablosuz .setDNS (dns_server1)
Kablosuz .setDNS (dns_server1, dns_server2)
Parametreler
dns_server1 : birincil DNS sunucusunun IP adresi
dns_server2 : ikincil DNS sunucusunun IP adresi
İadeler
Hiçbir şey değil
Misal
This example shows how to set the Google DNS (8.8.8.8). You can set it as an object IPAddress.
#include <SPI.h>
#include <WiFiNINA.h>
// the IP address for the shield:
IPAddress dns(8, 8, 8, 8); //Google dns
char ssid[] = "yourNetwork"; // your network SSID (name)
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;
void setup()
{
// Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
// print your WiFi's IP address:
WiFi.setDNS(dns);
Serial.print("Dns configured.");
}
void loop () {
}
#include <WiFiNINA.h>
// the IP address for the shield:
IPAddress dns(8, 8, 8, 8); //Google dns
char ssid[] = "yourNetwork"; // your network SSID (name)
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;
void setup()
{
// Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
// print your WiFi's IP address:
WiFi.setDNS(dns);
Serial.print("Dns configured.");
}
void loop () {
}
See Also
- begin()
- end()
- beginAP()
- beginEnterprise()
- disconnect()
- config()
- setHostname()
- setTimeout()
- SSID()
- BSSID()
- RSSI()
- channel()
- encryptionType()
- scanNetworks()
- ping()
- status()
- macAddress()
- firmwareVersion()
- lowPowerMode()
- noLowPowerMode()
- reasonCode()
- hostByName()
- localIP()
- subnetMask()
- gatewayIP()