You need to set appropriate server, port and remote driver.
For example you can set following properties in application property file.
selenium.server=<ip or machine name>
selenium.port=<port used by grid/server normally 4444>
The same can be provided either by command line as system property or in testNG configuration file as parameter.