How to start wiremock standalone with custom hostname? - wiremock

For example, I want to start wiremock standalone with hostname "my.abc.com" with port 9999. Where can I config that? Or what is the right command line options for hostname?
Thanks a lot in advance.

The hostname is determined by DNS or your host file, rather than WireMock itself.
If you want to run everything locally but with a hostname other than localhost you can edit your hosts file and add a line like:
127.0.0.1 api.mydomain.com
Then you can hit a locally running WireMock server on e.g. http://api.mydomain.com:9999/
As agoff points out, if you want to use the Java DSL against the instance you need to configure it:
WireMock.configureFor("api.mydomain.com", 9999);
The host file can be found in the following places:
Windows - c:\Windows\System32\Drivers\etc\hosts
Mac - /private/etc/hosts
*nix - /etc/hosts

Related

MongoDB: DNS issue of resolv.conf connecting to MongoDB

I want to export some data from MongoDB Atlas.
If I execute the command below, It tries connect localhost and export the data.
mongoexport --uri="mongodb+srv://<username>:<password>#name-of-project-x2lpw.mongodb.net/test" --collection users --out /tmp/testusers.json
Note: If you run this command from Windows CMD, it works fine
After researching the problem and with the help of a user, everything seems to point to a DNS problem and to the related resolv.conf file.
Below the original /etc/resolv.conf:
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
search name.com
At the beginning that resulted into a connection failure as shown below:
But if I would change that address into the following public available address according to what advised on this post to 1.1.1.1 the connection is successful, see below:
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 1.1.1.1
options edns0
search name.com
Which resulted into a connection success as shown below:
HOWEVER the problem is that instead of explicitly connecting to the name of the MongoDB cluster, it will connect to the localhost, which is very strange as I successfully exported the files I was looking for from the real connection.
Which means that the machine was correctly connecting to the database but via localhost.
Everything seems to lead, also according to this source and also here to a DNS problem while connecting to MongoDB via terminal to export collections.
Now from this last post it not advisable to manually change this address for several reasons, therefore right after successfully exporting the data using DNS 1.1.1.1 I changed it back to its original DNS 127.0.0.53.
However I don't think this should be a proper behavior as every time I need to export data I will have to continuously and manually change this address.
What could be the reason for this strange behavior? And therefore what could be a long term solution without manually switching between DNS addresses?
Thanks for pointing to the right direction for solving this issue.
It seems you all ready have the answer in the links you mentioned. I will summarize this:
Install resolvconf (for Ubuntu apt install resolvconf), add the line nameserver 8.8.8.8 to /etc/resolvconf/resolv.conf.d/base, then run sudo resolvconf -u and to be sure service resolvconf restart.
To verify run systemd-resolve --status.
You should see on the first line your DNS server like here:
DNS Servers: 8.8.8.8
DNS Domain: sa-east-1.compute.internal
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
This solution persists between reboots.

can ping 8.8.8.8 but not google.com

I just got a new router and internet connection.
My phone and my second computer have no problem to connect to internet (wifi or cable). My first computer, where I am running Limux Mint 18.1 Serena, can connect with cable or wifi but I am unable to browser.
I can ping 8.8.8.8 but not google.com.
I do not understand much of DNS but I tried to follow some online tutorials.
I tried to modify the /etc/resolconf directory by adding a resolv.conf file with a new servername but didn't work (even after restarting network-manager). I tried as well to modify the /etc/resolv.conf.d/tail file (as read in other tutorials) by adding a new servername but still not working.
Any suggestion?
Your DNS resolving doesn't work.
Check your firewall for an open port UDP/53 to 8.8.8.8
# iptables -L -n -v
Check with your ISP for DNS server provided. They are probably blocking UDP/53 somewhere on the way out to force you to use internal DNS server.
If you are on DHCP, renew the lease.
Depends on distro (most probably networkmanager, ifdown/ifup combination may work as well). This happens quite often with resolvconfd and dnsmasq. You may need to restart the NetworkManager then
Again - command depends on distro, usually with systemd
# systemctl restart NetworkManager
If you are on static IP and have noone to ask or check their config, you may sniff (tcpdump -nnvv -i <interface> udp port 53).
The problem occurs due to trouble with DNS setting
If you are using linux follow:
Clear this file content (root permission required)
nano /etc/resolv.conf
Add the folling text:
nameserver 1.1.1.1
nameserver 8.8.8.8
Save and Reboot
If using Windows Follow:
Control Panel\Network and Internet\Network and Sharing Center
Select current active connection (wifi/broadband)
Properties > Networking > ipv4 > custom dns > 1.1.1.1 & 8.8.8.8
check Validate setting upon exit > save

run a distribution test with jmeter in Vm Centos

I'm trying to run a distribution test for learning purpose and i'm using a Virtual machine Centos 7 as a slave in my Windows 7 ( master running in window 7) but even if i configure the master with the IP of the slave ( VM ), modifying the file jmeter.properties, doesn't work, i try run Jmeter-server in the Centos machine but this problem appears.
Created remote object: UnicastServerRef [liveRef: [endpoint:[127.0.0.1:44341](lo
cal),objID:[4e68a212:14a8564a618:-7fff, 5760053273490727502]]]
Server failed to start: java.rmi.RemoteException: Cannot start. localhost.locald
omain is a loopback address.
An error occurred: Cannot start. localhost.localdomain is a loopback address.
Can somebody give me a direction where look or a explanation how can i do it?
Thanks!
Put the following line in system.properties file: java.rmi.server.hostname=xxx.xxx.xxx.xxx
Alternatively start JMeter providing above property as a command-line argument as:
jmeter (or jmeter-server) -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx
Double check your network configuration, i.e. make sure that your /etc/hosts file contains the following lines:
127.0.0.1 localhost localhost.localdomain
xxx.xxx.xxx.xxx your CentOS machine hostname
In all above cases xxx.xxx.xxx.xxx should be IP address of your CentOS machine and this IP address must be different from 127.0.0.1.
Also make sure that you select "Bridged" networking in your Virtual Machine, machines should be able to reach each other over the network, firewalls should be properly configured to allow communication, etc.
For more information on different JMeter Properties and ways of setting/overriding them see Apache JMeter Properties Customization Guide

Using "http://localhost" instead of "http://xx.xx.xx.xx" on iPod on WAMP

I am running Windows 7 and use my iPod Touch to access my localhost sites for testing purposes on WAMP.
I can browse my localhost sites by navigating to my machine IP in Safari on my iPod like so: http://10.0.0.100
I would like to know if it is at all possible to use http://localhost instead, and how I can accomplish that.
Thank you very much!!
Basically, localhost refers to 127.0.0.1 refers to the loop back ip which is the ipod itself so it's not possible unless you change [localhost to resolve to machine IP which is in this case 10.0.0.100] in the (DNS / hosts file) your ipod is using to resolve domain names in your connection settings and I don't recommend that.
Following are the steps needed to change the hosts file in your ipod (I warned you already this is not a good thing unless you know what are you doing)
source: https://discussions.apple.com/thread/2801892?start=0&tstart=0
Simple solution:
the hostfile is located at: /etc/hosts
To edit this file you need to SSH into your device, If you know how to do this directly just use vi, or nano to edit the file. From windows use WinSCP to access the file system via FTP(SSH). Then simply navigate to /etc/hosts download the file to your desktop, right click and open it with note pad, add your resolver to the last line "192.168.0.100 testserver", save, and replace the original file with the new one.
/etc/host -- example config
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.0.100 testserver
*To SSH into an ipod it must have OpenSSH installed, usually this requires a jailbreak.

How to assign hostname to the web server?

I am using lighttpd as my webserver.
Currently I am accessing it using the IP address as :
http://192.168.0.1
I want to access it as
http://myhostname.com
I would be using it in the local network only, and not the internet.
I don't know how to do this. I googled, but don't know the exact keywords to use.
Put the following line to the file /etc/hosts:
192.168.0.1 myhostname.com
For instance, using the following command:
$ sudo echo -e '192.168.0.1\tmyhostname.com' >> /etc/hosts
you can add a rule in your hosts file: C:\Windows\System32\drivers\etc\hosts
add a rule like
192.168.0.1 myhostname.com
In windows you can't do this with wildcards so for all subdomains you need to add a rule
Find your hosts file on your local machine, and then add the following line to it:
192.168.0.1 www.somedomain.com