Ethernet.setGatewayIP()

名称

Ethernet.setGatewayIP()

説明

ネットワークゲートウェイのIPアドレスを設定する。DHCPのときは利用しない。

書式

void EthernetClass::setGatewayIP(const IPAddress gateway);

引数

gatewayネットワークゲートウェイのIPアドレス。

戻り値

なし。

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
IPAddress myDns(192, 168, 1, 1);
IPAddress gateway(192, 168, 1, 1);

void setup() {
  Ethernet.begin(mac, ip, myDns, gateway);
  IPAddress newGateway(192, 168, 100, 1);
  Ethernet.setGatewayIP(newGateway);  // change the gateway IP address
}

void loop () {}

オリジナルのページ

https://www.arduino.cc/reference/en/libraries/ethernet/ethernet.setgatewayip/

最終更新日

January 7, 2024

inserted by FC2 system