Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Codesys Linux SL - Setup of EoE

  • shaunvdm

    shaunvdm - 2021-08-26


    Where can i find information related to setup of ethernet over ethercat.
    Anything special to setup on Linux?


  • eschwellinger

    eschwellinger - 2021-08-27

    basically you need to use a tap device to do it:

    set up tap0 device

    /sbin/ip tuntap add tap0 mode tap
    /sbin/ip link set tap0 up
    /sbin/ip addr add dev tap0

    maybe you need to add a route additional
    echo 1 >/proc/sys/net/ipv4/ip_forward' ...

  • shaunvdm

    shaunvdm - 2021-11-04

    Hi Edwin,

    Herewith a solution that works to enable the EoE on debian linux.

    Step 1
    Edit the network settings
    nano /etc/network/interfaces

    add the following:

    auto tap0
    iface tap0 inet manual
    pre-up ip tuntap add tap0 mode tap user root  # or use a different user profile. 
    up ip link set dev tap0 up
    post-up /usr/local/sbin/enablebr0.sh  # script to enable the br0 bridge
    post-down ip link set dev tap0 down
    down ip link set dev tap0 down

    Save the file then

    Make the enablebr0.sh script

    nano /usr/local/sbin/enablebr0.sh
    Contents of script---- Where enp1s0 put your network adaptor name / where the put your desired ip address.

    add the following:

    ip link add br0 type bridge
    ip link set tap0 master br0
    ip link set enp1s0 master br0
    ip link set dev br0 up
    ip addr add dev br0

    Save the script. Remember to make it executable (chmod +x /usr/local/sbin/enablebr0.sh)

    Hope this helps someone.


    Last edit: shaunvdm 2021-11-04
  • eschwellinger

    eschwellinger - 2021-11-05

    many thanks for this.

  • mrupf

    mrupf - 2021-11-29


    Got lost on this explanation on which IP and adapter goes where.

    In my setting the:
    - EoE device has the IP -> this is what I put into the enablebr0.sh (
    - EtherCat runs on eth0 -> this is the adapter for enp1s0?
    - eth0 has a IP configured to be
    - eth1 has a IP configured to be This is where the PC is connected to the raspberry PI.
    - on my PC I have a route to MASK

    With this I'm able to ping

    If I add the tun/tap (accodring to shaunvdm) I'm able to ping, but even with EtherCat not running. So I guess I've gone wrong somewhere, as I just ping the br0 bridge.

    Any hints on where I'm going wrong?

  • shaunvdm

    shaunvdm - 2021-12-05


    Yes you got this totally mixed up.

    Your EoE address range must be the same as the programming port NOT Ethercat as this uses alias and not IP addresses.

    So in short

    Change the Enablebr0.sh to the programming port address ie (In the Network interfaces set the eth1 to manual similar to the tap port (auto eth1 iface eth1 inet manual)
    (This bridge connection replaces your normal Eth1 definition to enable a bridge between Tap and physical interface to Ethercat)

    In Codesys make sure you use the EoE on the 192.168.0.XXX range for the drives or whatever you want to talk to over Ethercat with ethernet protocol.

    No routing required besides the information i provided in my post.

    Let me know....

  • mrupf

    mrupf - 2021-12-06

    That clears a lot! Thanks.

    I used in the enablebr0.sh.
    This to have a difference between the origin eth1 ip address and the /24 to have the same subnet (
    With /16 ( I had issue on reaching Guess due to missmatch in subnet settings.

    Anyway with this it now runs smooth!
    Two different device EoE parallel and EtherCat (48Byte PDO's to the two slaves) with 4ms.


    Last edit: mrupf 2021-12-06
  • mauri

    mauri - 2022-08-31

    Hello everybody,
    I did many tests, and it seems that something is wrong.
    I tested on Ubuntu 22.04, where the network management is different.
    So I moved to a DEBIAN 11 but it is still not working.
    At the end I can ping the ethernet port (in this note the eth1:, I can ping the bridge (br0: or but I cannot ping the ethercat device.
    Could someone explain to me which are the interfaces involved and how to place the right IP addresses.

    Thank you



Log in to post a comment.