IP Addressing, Subnets and VLANs

Addresses and masks, subnet math, gateways, DHCP and BOOTP, ports, VLANs and a machine-network design example.

IP addresses and subnet masks

Every device on an IP network has an IP address, a 32-bit number written as four decimal numbers (192.168.10.10), and a subnet mask that splits the address into a network part (which must be the same for devices that talk directly) and a device part (unique within the network). A mask of 255.255.255.0 means the first 24 bits are the network: all devices from 192.168.10.1 to 192.168.10.254 are on the same subnet. The same mask is written /24, the number of network bits.

IPv4 address 192.168.1.10 with mask 255.255.255.0 (/24)IP address11000000192101010001680000000110000101010Subnet mask111111112551111111125511111111255000000000Network (AND)1100000019210101000168000000011000000000Broadcast110000001921010100016800000001111111111255network part (mask bits = 1): must match for two devices to be on the same subnetdevice part (mask bits = 0): 254 usable addresses (.0 is the network, .255 is the broadcast)
The address 192.168.10.10 and mask 255.255.255.0 in binary: the network part, the device part, the network address and the broadcast address.
ItemExampleWhat it is
IP address192.168.10.10Unique on the network
Subnet mask255.255.255.0 (/24)Says which bits are network and which are device
Network address192.168.10.0The address with all device bits 0: names the subnet; not assignable
Broadcast address192.168.10.255The address with all device bits 1: every device on the subnet; not assignable
Default gateway192.168.10.1The router for traffic to other subnets; leave blank on an isolated network
MAC address00:1B:1B:12:34:56The fixed hardware address; used on the local segment and to find a device with no IP

Subnet arithmetic

PrefixMaskAddressesUsable devicesNote
/8255.0.0.016 777 21616 777 214
/16255.255.0.065 53665 534
/20255.255.240.04 0964 094
/22255.255.252.01 0241 022
/23255.255.254.0512510
/24255.255.255.0256254one “class C” network
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242

The number of usable device addresses is 2(32 − prefix) − 2 (the network and broadcast addresses are not assignable). A quick method for the last octet: the block size is 256 minus the mask value, and subnets start at multiples of the block size. For mask 255.255.255.192 the block size is 64, so the subnets start at .0, .64, .128 and .192.

Worked example: splitting a network into four

A machine builder has 192.168.10.0/24 and wants four separate subnets of up to 60 devices. Four subnets need 2 extra network bits (22 = 4), so the prefix is /26 (mask 255.255.255.192), with 26 − 2 = 62 usable addresses each.

SubnetUsable addressesBroadcastUse
192.168.10.0 / 26192.168.10.1 to 192.168.10.62192.168.10.63PLC and I/O
192.168.10.64 / 26192.168.10.65 to 192.168.10.126192.168.10.127Drives
192.168.10.128 / 26192.168.10.129 to 192.168.10.190192.168.10.191HMI and SCADA
192.168.10.192 / 26192.168.10.193 to 192.168.10.254192.168.10.255Spare

Worked example: are they on the same subnet?

  • With mask 255.255.255.192, is 192.168.10.70 on the same subnet as the PLC at 192.168.10.10? The PLC is in the 192.168.10.0 block (addresses 0 to 63); 70 is in the block starting at 64. Different subnets: they cannot talk directly and need a router.
  • Is 192.168.10.40 on the PLC’s subnet? 40 is in 0 to 63. Yes, the same subnet.
  • A widely-used shortcut: write both addresses in binary, apply the mask, and compare the results. Equal means same subnet. This is exactly what a device does before sending a packet.

Worked example: widening the mask to join two ranges

  • A PLC at 192.168.1.10 and a drive at 192.168.2.30, both with mask 255.255.255.0, are on different subnets (1.0 and 2.0) and cannot talk without a router.
  • Changing both masks to 255.255.252.0 (/22) makes one subnet from 192.168.0.0 to 192.168.3.255 (network 192.168.0.0, broadcast 192.168.3.255), so 192.168.1.10 and 192.168.2.30 are now neighbors. A /22 has 1 022 usable addresses; the mask must change on every device in the range.
  • A /23 (255.255.254.0) joins just two /24 ranges and gives 510 usable addresses. The simpler fix is to give the drive 192.168.1.30 with the original mask.

Gateways and routing

Subnet 192.168.1.0 / 24Subnet 192.168.2.0 / 24Laptop192.168.1.50HMI192.168.1.20PLC192.168.2.10Drive192.168.2.30Router.1.1 | .2.1to gatewayA device sends a packet directly only if the destination is on its own subnet. Otherwise it sends it to its default gateway.No gateway (or a wrong one) is the classic reason one device can be pinged from one side but never answers back.
Two subnets joined by a router: devices reach other subnets through their default gateway.

A device sends directly only to addresses in its own subnet. For any other address it sends the packet to its default gateway, a router on its own subnet, which forwards it. That needs the router’s address (the gateway) on both devices: the reply has to find its way back. A common fault is a device that can send out but never receives answers because its own gateway is blank or wrong.

  • No gateway needed when all devices are on one subnet; leave it blank or 0.0.0.0. A wrong gateway can cause odd delays.
  • Routers and firewalls are the controlled doors between subnets: they allow only the traffic you list (see Industrial Network Security).
  • Static routes tell a router about a network that is not directly attached (for example a second machine network behind another router).
  • Broadcasts and discovery do not cross routers. BOOTP, PROFINET DCP and many vendor browse tools work only on the local segment.
  • Layer-3 switches route between VLANs at wire speed; a router on a stick does the same over one trunk.

Private addresses and NAT

RangePrefixAddressesUse
10.0.0.0 to 10.255.255.25510.0.0.0/816 777 216Large plants and companies
172.16.0.0 to 172.31.255.255172.16.0.0/121 048 576Medium networks
192.168.0.0 to 192.168.255.255192.168.0.0/1665 536Machines and small networks
169.254.0.0/16link-local65 536Self-assigned when no DHCP answers: a device with a 169.254 address has not got its real one
127.0.0.1loopback1This computer itself

Private addresses are not routed on the internet: they are for inside the plant. NAT (network address translation) in a router or firewall maps addresses between two networks. In industrial use it lets identical machines, each with the same internal addresses (192.168.10.x), connect to one plant network, each appearing there with a different address. 1:1 NAT maps one outside address to one inside address; many-to-one NAT hides a whole network behind one address. NAT is a convenience and not a security measure.

Assigning addresses: static, DHCP, BOOTP

New deviceno address yetDHCP / BOOTP server1. Discover (broadcast): “I need an address; my MAC is …”2. Offer: “You can have 192.168.10.30, mask, gateway”3. Request: “I take 192.168.10.30”4. Acknowledge: “Confirmed, lease of N hours”Drives and PLCs often use fixed addresses; BOOTP tools (Rockwell, Siemens PRONETA, vendor tools) assign one by MAC address once.A device that depends on DHCP can change its address after a power cut: use reservations by MAC for control devices.
A DHCP exchange: discover, offer, request, acknowledge.
MethodHow it worksUse forWatch for
Static (manual)You type the address into the devicePLCs, drives, HMIs, remote I/O: everything that other devices must findDuplicates; keep an address list
DHCPA server hands out an address, mask and gateway for a lease timeLaptops, phones, guestsA control device that depends on DHCP can change address after a power failure
DHCP reservationThe server always gives the same address to a given MACControl devices when you want central managementThe server must be up at power-on
BOOTPA device with no address asks a tool; the tool answers by MAC addressFirst commissioning of Rockwell and many other devicesTurn BOOTP off after assigning so that the address stays
DCP (PROFINET)The controller assigns the address to the device that has the right namePROFINETThe name must match
Link-local (169.254)Self-assigned when nothing answersNothing deliberateMeans the address was not obtained
  • Reserve a range for DHCP (for example .100 to .199) and keep static addresses outside it.
  • Use one convention: PLC at .10, HMI at .20, drives from .30, remote I/O from .40, laptops at .50 and up.
  • Keep all devices of one machine in one subnet unless a router is part of the design.

Ports and the services behind them

An IP address finds a device; a port number (0 to 65 535) finds the program inside it. TCP ports belong to connections; UDP ports to datagrams. A firewall rule usually names a port.

PortProtocolUsed byNotes
TCP 502Modbus TCPAlmost every brandNo security; keep inside the machine network
TCP 44818, UDP 2222, UDP 44818EtherNet/IPRockwell, Omron, many drivesExplicit messaging on 44818; I/O on 2222; discovery on UDP 44818
TCP 102S7 communicationSiemens S7, HMIs, driversThe S7-1200/1500 needs PUT/GET enabled
UDP 34964, 49152 and upPROFINET (non-real-time)PROFINET devicesRT frames use EtherType 0x8892, not IP
TCP or UDP 9600FINSOmronConfigurable
TCP 4840OPC UAEverywhereSecure when configured; see OPC UA, MQTT and Industrial IoT
TCP 1883, 8883MQTT, MQTT over TLSIoT gateways, brokersUse 8883
TCP 80, 443HTTP, HTTPSDevice web pagesPrefer HTTPS; disable if unused
UDP 161, 162SNMPMonitoringUse SNMPv3 where possible
TCP 22, 23SSH, TelnetAdministrationTelnet is unencrypted: disable it
TCP 3389Remote DesktopWindows engineering PCsNever expose to the internet
UDP 67, 68DHCP, BOOTPAddress assignmentBroadcast-based; local segment only
UDP 123NTPTime synchronizationNeeded for correct timestamps in logs

VLANs

A VLAN (virtual LAN, IEEE 802.1Q) divides one physical switch into several separate networks. Each port is assigned to a VLAN; frames are tagged with a VLAN number (1 to 4094) when they travel on a trunk port between switches, and devices in different VLANs can talk only through a router. VLANs keep control traffic apart from everything else without separate switches.

Managed switchports assigned to VLANs; trunk port carries tagsVLAN 10: controlPLC, drives, remote I/OVLAN 20: supervisionHMI, SCADA, engineeringVLAN 30: othercameras, guests, voiceRouter / firewallrules between VLANstrunk (802.1Q tags)Devices in different VLANs cannot talk to each other except through the router, where you decide what is allowed.
One managed switch divided into three VLANs, with a router and a trunk.
TermMeaning
Access portBelongs to one VLAN; the device on it knows nothing about VLANs
Trunk portCarries several VLANs between switches or to a router, with a tag on each frame
Native / untagged VLANThe VLAN whose frames travel without a tag on a trunk; a mismatch between two ends is a classic fault
VLAN IDThe number 1 to 4094; use the same numbers everywhere
Inter-VLAN routingA router or layer-3 switch forwards between VLANs under your firewall rules
Priority tag (802.1p)Three bits in the tag that give real-time frames priority (PROFINET RT uses 6)
  • Plan the VLANs on paper: a number, a name, a subnet, a purpose.
  • One VLAN, one subnet. Map each VLAN to its own IP subnet.
  • Leave real-time protocols inside one VLAN: PROFINET RT, EtherCAT and DCP discovery do not cross routers.
  • Disable unused ports or put them in an unused VLAN.

A machine-network design

Managed switchmachine network 192.168.10.0 / 24PLC192.168.10.10HMI192.168.10.20Drive 1192.168.10.30Drive 2192.168.10.31Remote I/O192.168.10.40Laptop192.168.10.50Firewall / routerLAN .10.1 | plant 10.20.30.5Plant network10.20.30.0 / 24The machine uses private addresses and is invisible to the plant. Only the rules you write let SCADA readthe PLC (for example TCP 44818 or 502 to .10 only). The same layout can be repeated on every machine.Keep a table of every address, and keep static addresses outside any DHCP range.
A typical machine network behind a firewall with address translation.
DeviceAddressRoleAllowed from the plant network
PLC192.168.10.10Controller; Modbus TCP server and EtherNet/IP adapterTCP 44818 and 2222 from SCADA; TCP 502 only from the historian
HMI192.168.10.20Operator panelWeb (HTTPS) from the engineering station only
Drive 1, Drive 2192.168.10.30, .31Servo and VFDNone; reached only by the PLC
Remote I/O192.168.10.40Distributed I/ONone
Laptop192.168.10.50Service connectionPlugged in during service only
Firewall192.168.10.1 | 10.20.30.5Machine side and plant sideThe rules in this table

The same layout can be copied to every machine: the internal addresses are identical, and NAT gives each machine one address on the plant network. See System Integration for putting several machines together.

Command-line tools for checking

Command (Windows)What it tells youReading the result
ipconfig /allThe laptop’s own addresses, masks and gatewaysIs the laptop on the right subnet? Are several adapters active?
ping 192.168.10.10Does the device answer at the network layer?Replies and times prove cable, address and subnet; “Request timed out” means no answer; “Destination host unreachable” means no route
ping -t 192.168.10.10A continuous pingWiggle a cable and see when the replies stop
arp -aThe IP and MAC pairs the PC knowsA device that appears twice, or the same MAC for two IPs, shows a duplicate IP
tracert 10.20.30.50The routers a packet passes throughShows where the path ends
netstat -anOpen connections and listening ports on the PCIs the connection to port 502 established?
Test-NetConnection 192.168.10.10 -Port 502 (PowerShell)Is a TCP port open?TcpTestSucceeded True means something is listening
nslookup nameName to addressRarely needed on a machine network

Some devices do not answer ping (a setting or a firewall), so a failed ping does not always mean the device is dead; check the link light and ARP too.

Setting the address on each platform

PlatformHow the address is usually setNotes
Allen-Bradley LogixBOOTP/DHCP tool, Studio 5000 (port configuration), RSLinx, or module switchesA new device may have BOOTP enabled: assign an address, then disable BOOTP so that it keeps it
Allen-Bradley Micro800Connected Components Workbench (Ethernet), or BOOTPStored in the controller
Siemens S7-1200/1500TIA Portal device configuration; Online and diagnostics; PRONETA; device name for PROFINET devicesFor S7 communication enable PUT/GET access
Mitsubishi iQ-F, iQ-RGX Works3 module parameters, then write to the PLCProtocol ports are separate from the IP address
Omron CP, CJ, NX, NJCX-Programmer or Sysmac Studio, first over USB or serialFINS node numbers follow the last IP number by default on some units
IDEC FC6AWindLDR communication settingsProtocols enabled separately
Unitronics Vision, UniStreamSetIP utility or the hardware configurationIP and port settings are in the project
AutomationDirect Click, ProductivityThe programming software’s communication settingsModbus TCP is built in
CODESYS-basedThe device’s web page, the CODESYS gateway or a vendor toolVaries by vendor

The steps and menu names change between software versions; check your manual. The principle does not: put the PC on the same subnet, find the device (by its MAC address or a browse), assign a fixed address, save it, and check with ping. Step-by-step recipes are on Connecting PLCs, Drives and HMIs.

An address plan template

DeviceLocationIP addressMaskGatewayMACName / unit IDProtocol and port
PLC_1Panel A192.168.10.10255.255.255.0192.168.10.100:1B:1B:…plc1EtherNet/IP 44818
HMI_1Door192.168.10.20255.255.255.0192.168.10.1…hmi1S7 / OPC UA
VFD_1Panel B192.168.10.30255.255.255.0(blank)…unit ID 1Modbus TCP 502
(blank row)

Keep the real table with the drawings, and update it on every change. Add serial devices on a second table: station address, baud rate, parity, stop bits, register map reference.

Common mistakes

MistakeWhat you seeFix
A different subnet from the PLC (laptop on 192.168.0.x, PLC on 192.168.1.x)No ping, software cannot find the deviceSet the laptop to the PLC’s subnet
A duplicate IP addressA device drops in and out; ARP shows two MACs for one IPFind the other device; fix the address list
Wrong mask on one deviceIt can talk to some devices and not othersCheck the mask on every device
No gateway (or a wrong one) on a device across a routerRequests arrive; replies never returnSet the correct gateway on both sides
DHCP address changed after a power cycleThe HMI and PLC lose contactUse a static address or a reservation
BOOTP left enabledThe device returns to a different address after a power cycleDisable BOOTP after assigning
Two network cards on the laptop on the same subnetThe software uses the wrong oneDisable Wi-Fi or set the adapter order
Broadcast tools used through a routerThe device is not found though it is thereConnect the laptop to the same subnet
Port blocked by a firewallPing works but the protocol failsOpen the port (and only that port)

Related

FAQ

What mask should I use?

The one that is on every device of the machine: 255.255.255.0 (/24) is the usual default. Use a smaller subnet (/26 or /27) only when you want to divide a range, and then change the mask on every device in it.

Why can I ping the PLC but not connect with the programming software?

Ping proves layers 1 to 3. The software uses a TCP port and a protocol: check the port is open, the protocol settings (for example the right driver, PUT/GET access) and any firewall.

Why does my device have a 169.254 address?

It asked for an address (DHCP or BOOTP) and nobody answered, so it gave itself a link-local one. Assign a static address, or fix the DHCP server.

Do I need a default gateway?

Only if the device must talk to another subnet. For devices on one machine network, leave it blank.

Should I use VLANs on a small machine?

Not necessarily. A small machine can be a single flat subnet. Use VLANs when different kinds of traffic share one switch, or when a plant policy requires separation.

What is the difference between a switch and a router?

A switch connects devices on the same subnet. A router connects different subnets. Many managed switches also route between VLANs (layer 3).

References

  • RFC 791, Internet Protocol; RFC 950, Internet Standard Subnetting Procedure; RFC 4632, Classless Inter-domain Routing (CIDR).
  • RFC 1918, Address Allocation for Private Internets; RFC 2131, Dynamic Host Configuration Protocol; RFC 951, Bootstrap Protocol (BOOTP).
  • IEEE 802.1Q, Bridges and Bridged Networks (VLANs).
  • Rockwell Automation, EtherNet/IP Network Devices User Manual (ENET-UM006) and Converged Plantwide Ethernet (CPwE) Design and Implementation Guide (with Cisco).
  • Siemens, PROFINET with STEP 7 and S7-1200 System Manual.

Last reviewed: October 2026. Speeds, lengths, node counts and menu names are typical: confirm against the specification and the manufacturer’s documentation for the devices you use.