can't ping through ethernet



  • Hello everyone,
    i'm not able to ping the device connected to my omega2+ through ethernet, my device's IP is (192.168.0.3) and i changed the omega's IP to (192.168.0.7). can anyone help me ?



  • @Ghofran-Daoues it may be a firewall issue, on the Omega2 you can stop the firewall to see if this is the issue, using the command:

    service firewall stop

    The device your omega is connected to may also have a firewall. So testing ping from your computer to the Omega2 and from the Omega2 to your computer.

    If this does not work please post the output of ifconfig command.



  • @crispyoz thank you !! it worked after running :'service firewall stop'



  • @Ghofran-Daoues So it seems the firewall is blocking your ping. Were you trying to ping from your computer to your Omega2 or from your Omega2 to your computer?



  • i was trying to ping from the omega to my pc, and to an another device (a servo-drive), actually now it pings, but still it can't connect to the servo drive through ethernet.
    ps : i'm using the pymodbus library in order to connect to this device it worked with my pc but not with the omega here's the code
    from pymodbus.client.sync import ModbusTcpClient
    import time

    client = ModbusTcpClient('192.168.0.3',502)
    conected = client.connect()
    print(conected)
    time.sleep(1)
    #OVERRIDE
    client.write_register(4,16384)
    client.write_register(9,16384)
    client.write_register(10,16384)
    #enable power stage
    client.write_register(0,1030)
    #time.sleep(0.01)
    client.write_register(0,1031)
    #time.sleep(0.01)
    client.write_register(0,1039)
    #time.sleep(0.01)
    print("Power stage enabled")
    #disable power stage
    time.sleep(2)
    client.write_register(0,0)
    time.sleep(1)
    client.close()



  • @Ghofran-Daoues OK so first you need to check if the Omega2 can get to the port. An easy solution is to run the nmap command I gave you in the previous thread. nmap -p 502 192.168.0.3

    BTW if you don't want to fix your firewall rules, and just keep the firewall down, you can use the command service firewall disable so the firewall will not come back up when you reboot.



  • the other time i tried to run the nmap command but coudn't it find it (nmap) and i couldn't install
    command not found/ unknown package



  • @Ghofran-Daoues you can use the nc command instead. nc 192.168.0.3 502

    If the port is closed or inaccessible then you'll get a connected refused error, if the port is accessible you'll just get a flashing cursor, press enter and you should get something back from port.

    If you cannot connect then post the output of the route command.



  • Capture d'écran 2024-06-21 110043.png
    apparently this is my problem !



  • Capture d'écran 2024-06-21 110427.png

    The output of route command !



  • @Ghofran-Daoues ok so earlier you said you can ping the device (192.168.0.3) after stopping your firewall. The error you have here indicates your Omega2 can't even ping device. So my guess is the firewall has restarted. So let's get back to the basics again. Stop and disable your firewall:

    service firewall stop
    service firewall disable
    reboot

    ping 192.168.0.3
    nc 192.168.0.3 502
    route
    ifconfig

    Please post the output of all of these commands.

    Is your Omega2 ethernet connected directly to your device or is it connected via a switch/router?



  • yes that's true it doesn't ping anymore
    here are my outputs :
    service firewall stop
    firewall stop.png
    ping 192.168.0.3
    nc 192.168.0.3 502
    route
    ping.png
    ifconfig
    ifconfig.png



  • @Ghofran-Daoues Look at the output of ifconfig, you can see your ethernet has no IPv4 address. Check your cable. You missed my last question: "Is your Omega2 ethernet connected directly to your device or is it connected via a switch/router?"

    If your Omega2 is connecting directly to the device using an ethernet cable then you need to set a static IP on the Omega2 ethernet unless your device runs a dhcpd, which is unlikely. So I need to understand how you are connected via ethernet.



  • omega2+ is directly connected using ethernet cable and the device doesn't run a dhcp, how to set a static ip on the omega ?



  • @Ghofran-Daoues this is controlled in the network config file (/etc/config/network), look for the entry for eth0, something like this:

    config interface 'wan'
    option ifname 'eth0'
    option proto 'dhcp'

    Change it to:

    config interface 'wan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '192.168.0.10'
    option netmask '255.255.255.0'

    Then run service network restart and try pinging etc again



  • even after setting an ip to the ethernet and disabling the firewall, it doesn't ping .

    the output of ifconfig and ping 192.168.0.3 :
    Capture d'écran 2024-06-21 160620.png



  • @Ghofran-Daoues That looks correct, check your cable and restart the device in case it has stopped listening.



  • At this moment, i think my problem is hardware-related, actually i broke my expansion dock and i did some tricks to use it again, i thaught it worked but since then he's not seeing the ethernet dock, and when i power the expansion dock the led is green (usually it's red)



  • @Ghofran-Daoues Your config looks correct now which is why I suggested checking cable and device. You might try plugging the ethernet cable into you computer, set a static IP in the same subnet
    then try to ping the Omega2 from the computer, if that fails then it's probably hardware.



Looks like your connection to Community was lost, please wait while we try to reconnect.