Juju mongo DB Replicaset Connecion String for Public Access

mongodb [primary] admin> rs.status()
{
  set: 'mongodb',
  date: ISODate('2024-08-05T10:02:01.322Z'),
  myState: 1,
  term: Long('3'),
  syncSourceHost: '',
  syncSourceId: -1,
  heartbeatIntervalMillis: Long('2000'),
  majorityVoteCount: 2,
  writeMajorityCount: 2,
  votingMembersCount: 2,
  writableVotingMembersCount: 2,
  optimes: {
    lastCommittedOpTime: { ts: Timestamp({ t: 1722852120, i: 4 }), t: Long('3') },
    lastCommittedWallTime: ISODate('2024-08-05T10:02:00.976Z'),
    readConcernMajorityOpTime: { ts: Timestamp({ t: 1722852120, i: 4 }), t: Long('3') },
    appliedOpTime: { ts: Timestamp({ t: 1722852120, i: 4 }), t: Long('3') },
    durableOpTime: { ts: Timestamp({ t: 1722852120, i: 4 }), t: Long('3') },
    lastAppliedWallTime: ISODate('2024-08-05T10:02:00.976Z'),
    lastDurableWallTime: ISODate('2024-08-05T10:02:00.976Z')
  },
  lastStableRecoveryTimestamp: Timestamp({ t: 1722852115, i: 4 }),
  electionCandidateMetrics: {
    lastElectionReason: 'electionTimeout',
    lastElectionDate: ISODate('2024-08-05T03:32:49.175Z'),
    electionTerm: Long('3'),
    lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
    lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1722619307, i: 4 }), t: Long('1') },
    numVotesNeeded: 2,
    priorityAtElection: 1,
    electionTimeoutMillis: Long('10000'),
    numCatchUpOps: Long('0'),
    newTermStartDate: ISODate('2024-08-05T03:32:49.397Z'),
    wMajorityWriteAvailabilityDate: ISODate('2024-08-05T03:32:50.343Z')
  },
  members: [
    {
      _id: 0,
      name: '240.0.72.226:27017',
      health: 1,
      state: 2,
      stateStr: 'SECONDARY',
      uptime: 23359,
      optime: { ts: Timestamp({ t: 1722852120, i: 2 }), t: Long('3') },
      optimeDurable: { ts: Timestamp({ t: 1722852120, i: 2 }), t: Long('3') },
      optimeDate: ISODate('2024-08-05T10:02:00.000Z'),
      optimeDurableDate: ISODate('2024-08-05T10:02:00.000Z'),
      lastAppliedWallTime: ISODate('2024-08-05T10:02:00.976Z'),
      lastDurableWallTime: ISODate('2024-08-05T10:02:00.976Z'),
      lastHeartbeat: ISODate('2024-08-05T10:02:00.515Z'),
      lastHeartbeatRecv: ISODate('2024-08-05T10:01:59.781Z'),
      pingMs: Long('0'),
      lastHeartbeatMessage: '',
      syncSourceHost: '240.0.72.150:27017',
      syncSourceId: 1,
      infoMessage: '',
      configVersion: 3,
      configTerm: 3
    },
    {
      _id: 1,
      name: '240.0.72.150:27017',
      health: 1,
      state: 1,
      stateStr: 'PRIMARY',
      uptime: 23371,
      optime: { ts: Timestamp({ t: 1722852120, i: 4 }), t: Long('3') },
      optimeDate: ISODate('2024-08-05T10:02:00.000Z'),
      lastAppliedWallTime: ISODate('2024-08-05T10:02:00.976Z'),
      lastDurableWallTime: ISODate('2024-08-05T10:02:00.976Z'),
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      electionTime: Timestamp({ t: 1722828769, i: 1 }),
      electionDate: ISODate('2024-08-05T03:32:49.000Z'),
      configVersion: 3,
      configTerm: 3,
      self: true,
      lastHeartbeatMessage: ''
    }
  ],
  ok: 1,
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1722852120, i: 4 }),
    signature: {
      hash: Binary.createFromBase64('XrqarAUjPG4pPzhSjsc9aq7FL9c=', 0),
      keyId: Long('7398524828891742215')
    }
  },
  operationTime: Timestamp({ t: 1722852120, i: 4 })
}

I deployed mongo Replicaset using juju charm and lxd but i need to access the cluster outside even i used the ip forwarding with the ip tables it’s only work for direct connect from the externally ,not working for the Replicaset access.i can access the replicaset internally without an issue.

Even i modified the host name to host ip it’s not getting persist when i exit out from the mongo shell it’s automatically revert back to this lxc containers’ ip.Is there any option to do achive my requirement without establishing VPN connection?