<p>I installed Istio with</p>

<pre><code>gateways.istio-egressgateway.enabled = true
</code></pre>

<p>When I try to connect to external database I receive an error.
I do not have a domain (only ip and port), so I define the following rules:</p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: external-db
spec:
  hosts:
  - external-db.tcp.svc
  addresses:
  - 190.64.31.232/32
  ports:
  - number: 3306
    name: tcp
    protocol: TCP
  location: MESH_EXTERNAL
  resolution: STATIC
  endpoints:
  - address: 190.64.31.232
</code></pre>

<p>then I open a Shell in my system (deployed in my service mesh)
And it can't resolve the name </p>

<pre><code>$ ping external-db.tcp.svc
ping: ceip-db.tcp.svc: Name or service not known
</code></pre>

<p>But i can connect using the ip address</p>

<pre><code>$ ping 190.64.31.232
PING 190.64.31.232 (190.64.31.232) 56(84) bytes of data.
64 bytes from 190.64.31.232: icmp_seq=1 ttl=249 time=1.35 ms
64 bytes from 190.64.31.232: icmp_seq=2 ttl=249 time=1.42 ms
</code></pre>

<p>What is happening? Do I have to connect using the domain or the ip?
 Can I define a internal domain for my external ip? </p>

user60108
<p>You can create headless service with hardcoded IP endpoint:    </p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: external-db
spec:
  clusterIP: None
  ports:
  - protocol: TCP
    port: 3306
---
apiVersion: v1
kind: Endpoints
metadata:
  name: external-db
subsets:
  - addresses:
    - ip: 190.64.31.232
    ports:
    - port: 3306
</code></pre>

<p>And then you may add to your ServiceEntry a host <code>external-db.default.svc.cluster.local</code></p>
