Commissioning in STEP 7
5.4 Communication between Linux and CPU
CPU 1505SP (F) Ready4Linux Version 2.7
56 Operating Instructions, 05/2019, A5E46864285-AA
Procedure
To establish external Web server access via NAT, proceed as follows:
1. Activate "packet forwarding" with the following command line:
sysctl -w net.ipv4.ip_forward=1
2. To add a rule to the prerouting and postrouting chain, enter the following command lines:
iptables -t nat -A PREROUTING -p tcp -i enp4s0 --src
192.168.2.0/24 --dport 4840 -j DNAT --to-destination 192.168.73.155:4840
iptables -t nat -A POSTROUTING --src 192.168.2.0/24 -j MASQUERADE
–
enp4s0
Name of the physical network interface assigned to the Linux operating system.
–
192.168.73.155
IP address of the runtime communication interface
–
192.168.2.0/24
Address of the subnet of the physical Ethernet interface assigned to the Linux
operating system.
–
4840
Port number of the OPC UA connection.
Note
Settings are lost after restart
The settings are lost after a restart. To save the setting,
you have the following options:
Use the "iptables-save" and "iptables-restore" commands.
Install the "iptables-persistent" package.
To check the NAT setting, enter the following command:
iptables -t nat -L
To delete the NAT setting, enter the following command:
iptables -t nat -F