how to access configuration module from service
To read the variables (configs) you'd do this:

$config = \Drupal::config('modulename.my_service');

$core_port = $config-&gt;get('modulename.core_port');


To write to the variables (configs) you'd do this:

// Set and save new message value.

$config = \Drupal::service('config.factory')-&gt;getEditable('modulename.my_service');
$config-&gt;set('modulename.core_port', 153760)-&gt;save();


There's an example you can look at in the core module aggregator.

It has a settings form at /core/modules/aggregator/src/Form/SettingsForm.php

and then it adds a route to access the settings form:

aggregator.admin_settings:
  path: '/admin/config/services/aggregator/settings'
  defaults:
    _form: '\Drupal\aggregator\Form\SettingsForm'
    _title: 'Feed aggregator settings'
  requirements:
    _permission: 'administer news feeds'


You could pretty much copy the form into your module and change the variables to match your config.

Generally you'll want to add the config in your service constructor.

namespace Drupal\modulename;

/**
 * Example Service with config.
 */
class MyService {


  /**
   * Drupal's settings manager.
   */
  protected $settings;

  /**
   * Constructor.
   */
  public function __construct() {
    $this-&gt;settings = \Drupal::config('modulename.my_service');
  }

}


Then you'd access the variables like this:

$this-&gt;settings-&gt;get('modulename.core_port');