Tbh, this is the first result for me when I Google for "ros multiple computers", but here you go: wiki/ROS/Tutorials/MultipleMachines.
That's not to say you cannot ask questions like this, but if you do, please let us know what you've already tried (to search for) yourself. It could be you've already found this page, but it wasn't clear to you how to use it, or something else caused you to still post a question here. If you don't tell us, we don't know and we run the risk of suggesting or telling you things you already know/have seen.
Edit:
the thing I tried was to setup a ros master and slave machines but my issue if I run roscore on the master machine I can't run it on the slave machine, I want to run roscore on both machine
this would have been something to mention in your OP, as a multi-master setup requires a bit more configuration (and software) than a regular one with just a single master.
I would suggest you take a look at multimaster_fkie and the tutorials on that page.
You'd still need to make sure you can get a regular single-master setup working though. The network requirements aren't that different.
If you are in the early stages of development and no hard decisions on ROS versions have been made yet you could also maybe look at ROS2. Where a setup like you describe is easy to create. There are quite some significant differences between ROS1 and ROS2 though and certain packages may not exist yet for ROS2. If your code-base is small you could consider upgrading/porting to ROS2. Just thought I'd let you know that the option is there.