Set IP address for systems with dhclient

DHCP is enabled by default in delivery state. If there is no DHCP server in the network, TwinCAT/BSD automatically assigns an IP address (169,254.x.x) after a timeout of five seconds. The alternative is a fixed IP address. This step shows how to set a fixed IP address in the console.

These settings are alternatively possible via the web interface of the Beckhoff Device Manager (see: Beckhoff Device Manager: web interface).

Proceed as follows:

1. Enter ifconfig in the console in order to query the network configuration. The Ethernet interfaces igb0 and igb1 of an industrial PC with two interfaces are listed in this sample. The interface igb1 is active and connected to a network.
igb0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
      options=4a024a9<RXCSUM,VLAN_MTU,JUMBO_MTU,VLAN_HWCSUM,LRO,WOL_MAGIC,RXCSUM_IPV6,NOMAP>
      ether 00:01:05:3d:69:12
      inet6 fe80::25b2:4227:1a65:b77a%igb0 prefixlen 64 scopeid 0x1
      inet 169.254.228.5 netmask 0xffff0000 broadcast 169.254.255.255
      media: Ethernet autoselect
      status: no carrier
      nd6 options=1<PERFORMNUD>
igb1: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
      options=4a024a9<RXCSUM,VLAN_MTU,JUMBO_MTU,VLAN_HWCSUM,LRO,WOL_MAGIC,RXCSUM_IPV6,NOMAP>
      ether 00:01:05:3d:69:13
      inet6 fe80::4207:801c:e08a:9ede%igb1 prefixlen 64 scopeid 0x2
      inet 172.17.42.57 netmask 0xfffffc00 broadcast 172.17.43.255
      media: Ethernet autoselect (100baseTX <full-duplex>)
      status: active
      nd6 options=1<PERFORMNUD>
2. Enter doas ee /etc/rc.conf in the console.
The file rc.conf opens in the editor.
3. Use the arrow keys to navigate below the entry ifconfig_default="DHCP" and add the following line:
ifconfig_igb1="inet 172.17.40.30 netmask 255.255.255.0"
4. Note the order of the entries in the configuration file. The system reads configuration files from top to bottom. Configuring a static IP address after the DHCP configuration overwrites the previous DHCP configuration. The default in ifconfig_default means that this configuration applies to all interfaces. The following entries can be used to partially or completely overwrite this configuration.
5. Define the IP address with inet and the subnet mask for the Ethernet interface igb1 with netmask.
6. Press [Esc] and select the option a) leave editor and subsequently a) save changes.
You have successfully set 172.17.40.30 as the fixed IP address. Enter the command doas service netif restart in the console to have the settings applied. Then check the network settings with the command ifconfig.