While we are trying to run and get the traceroute output using mtrpacket getting below error

import asyncio import mtrpacket # A simple coroutine which will start an mtrpacket session and # ping localhost async def probe(): async with mtrpacket.MtrPacket() as mtr: return await mtr.probe('10.11.12.13') # Use asyncio's event loop to start the coroutine and wait for the probe loop = asyncio.get_event_loop() try: result = loop.run_until_complete(probe()) finally: loop.close() # Print the probe result print(result) Error: mtrpacket.ProcessError: failure to communicate with subprocess "mtr-packet" (is it installed and in the PATH?) mtr-packet: Failure to open IPv4 sockets: Permission denied mtr-packet: Failure to open IPv6 sockets: Permission denied 

Any suggestions?

1

2 Answers

Probably socket permissions, try running with sudo access and that might do the trick.

1

mtr-packet is designed to run with raw socket access. If you are using Linux, you can use capabilities to grant the binary socket access. On other Unix-like operating systems, including MacOS, it should be suid root.

The following commands will grant it access to raw sockets.

For Linux:

sudo chown root $(which mtr-packet) sudo setcap cap_net_raw+ep $(which mtr-packet) 

For other operating systems:

sudo chown root $(which mtr-packet) sudo chmod u+s $(which mtr-packet) 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.