Checking Nameserver setup from command line - command-line

Is there a way to check if my domain is setup correctly on the nameservers? Ideally I'd like to run a command from command line, alternatively can use a third party tool.
for example, I'm trying to register a domain that's to be hosted on godaddy.com. I have set up the domain and can see it in my DNS list. The servers that are supposed to be setup are ns51.domaincontrol.com and ns52.domaincontrol.com, however my registration is bouncing saying that there are "No Nameservers found for {my new domain}".

I think this is the shortest and quickest command to list your nameservers:
host -t ns yourdomain.com

If you're on a Mac or Unix machine you can do the following from command line:
whois site.com
Toward the end it should give you a list of DNS servers.
You can filter the list, showing only the Name Server information, with:
whois site.com | grep "Name S"
Note that www.site.com and site.com are two different end points and you need to set up appropriately for both of them.

Zonecheck is a free software and can be run from the command line:
% zonecheck stackoverflow.com
ZONE : stackoverflow.com.
NS <= : ns51.domaincontrol.com. [216.69.185.26]
NS : ns52.domaincontrol.com. [208.109.255.26]
_______________
,---------------.|
~~~~ | warning || ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`---------------'
w> Nameservers are all part of the same AS
| Adv: ZoneCheck
| To avoid loosing all connectivity with the authoritative DNS in case
| of a routing problem inside your Autonomous System, it is advised to
| host the DNS on different AS.
`----- -- -- - - -
: All the nameservers are part of the same Autonomous System (AS number
: 26496), try to have some of them hosted on another AS.
`..... .. .. . . .
=> generic
==> SUCCESS (but 1 warning(s))

There is a built-in command line for that: nslookup
Submit it, then write set type=ANY and press enter. After which specify desired domain and you'll get what you are looking for. Alternatively, enter ? and see more options for the nslookup command line.
PS: while this answer comes with a delay, hope it to be useful for others who want to check nameserver/DNS setup from command line.

nm-tool run from the command line will give you much information, not the least of which is the DNS servers you're using. You may have to install this, but many distros have it included.

Related

Extract Content after Match

I would like to partially automate the configuration of our Aruba switch using the daily configuration *.cfg backups.
With the following command I get the desired block of a vlan from the Configfile:
$content=Get-Content -Path $switch.fullname | Select-String 'vlan 53' -Context 0,4
The result can then look like this, for example:
> vlan 53
name "WIFI"
tagged 5,8,47-52
no ip address
exit
Does anyone know how I can extract only the "tagged" vlan ports from $Content?
I would then like to use these in further steps for configuration.
Maybe via magic regex commands.
But unfortunately I am too stupid for that.
Many thanks in advance
Daniel

How to write this command line?

I'm using oh-my-zsh.
I want to make a zsh command mx google.com
And have it run the following:
dig +short mx $1
And then if I run
a p
where 'p' stands for "previous" (I'm open to other more common conventions here)
I want it to run (hypothetical if previous line outputs 3 IPs):
dig + short a ip1
dig + short a ip2
dig + short a ip3
for each result returned in the previous command.
The commands I want to support with the above convention are a, txt, mx, cname
This was currently all I had:
alias a='f() { dig +short a $1 };f'
but I am not sure how to combine the two.

How to change IP in the hosts file

I am trying to change the IP address set to a particular site in the host file.
For example :
# 123.123.123 www.google.com
# 456.456.456 www.google.com
I want to make a test that I enter Google through 123.123.123 and as the program changes and open Google through 456.456.456.
Changing the servers manually is removing the # from the beginning of the line.
I do not want to use selenium grid with some machines since any machine on another server do not have the resources for it.
I want to change this in the same machine while running through the code.
As the etc/hosts file is picked up immediately by the system without a restart you can manipulate or even completely overwrite this file during your run.
The trouble is that to edit the hosts file you need 'root' rights and you are actually changing the behaviour of your host system. In order to prevent this you might think about running in a docker environment but if that is not possible you can do something like this with root access:
/etc/hosts file
# 123.123.123 www.google.com
# 456.456.456 www.google.com
as part of your test run:
# at start of run
sed -i .bak 's/# 123.123.123/123.123.123/g' /etc/hosts
# do other tests now
# later when stuff has changed
sed -i .bak 's/123.123.123/456.456.456/g' /etc/hosts
Something like this?

Get (consistent) computer name in MATLAB

I occasionally need to customise MATLAB scripts depending on the machine it is being run on. I usually use the following command to grab the computer name:
char(getHostName(java.net.InetAddress.getLocalHost)
This returns a computer name in most cases. However, my laptop (a MacBook) varies depending on which network I am connected to.
Is there a way of retrieving some sort of unique identifier about the computer that does not change depending on the network it is connected to?
Update: I forgot to mention that I am looking for a solution that is OS independent. I need to find a command that works whether on Mac, PC or Linux.
A good identifier that is independent of network is the MAC Address (nothing to do with macbook). Every computer has a unique MAC Address. You can get it with this command on MATLAB:
system('ifconfig en0 | grep ether')
You will get something like that on the output:
ether 80:e6:50:28:76:d0
you can use the Hardware addresses of the computer’s network cards, as suggested here, extracting it with the following Matlab code:
not_win=true;
switch computer('arch')
case {'maci','maci64'}
[~,mac_add]=system('ifconfig |grep ether | grep -o -E "([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}"');
case {'glnx86','glnxa64'}
[~,mac_add]=system('ifconfig | grep HWaddr | grep -o -E "([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}"');
case {'win32','win64'}
not_win=false;
sid = '';
ni = java.net.NetworkInterface.getNetworkInterfaces;
while ni.hasMoreElements
addr = ni.nextElement.getHardwareAddress;
if ~isempty(addr)
sid = [sid, '.', sprintf('%.2X', typecast(addr, 'uint8'))];
end
end
otherwise, error('Unknown architecture')
end
if(not_win)
mac_add=regexprep(mac_add,'\r\n|\n|\r','.');
sid=upper(strrep(mac_add(1:end-1),':',''));
end
The sid variable contains the unique identifier you are looking for.
You have to detect the architecture of the machine, because java.net.NetworkInterface.getNetworkInterfaces does not properly work on Unix, returning only running interfaces; so you have to gathered mac addresses parsing the results of ifconfig (take a look here for some examples).
Pay attention! On Mac, if you start a Virtual Machine, fake network interfaces could be added, so the sid may change.

Servname not supported for ai_socktype

I'm running a Centos virtual machine using Vagrant. The machine seems to run properly, but when I try to sync Perforce I can see the following error:
[vagrant#vagrant-c5-x86_64 ~]$ /perforce/p4 sync -f ...
Perforce client error:
Connect to server failed; check $P4PORT.
failed.TCP connect to perforce.xxx.com:1666
Servname not supported for ai_socktype
I have read this http://www.ducea.com/2006/09/11/error-servname-not-supported-for-ai_socktype/ and tried to set the ports in /etc/services, but it didn't work. I am not even sure if the problem is Perforce or OS related.
Any hints?
I had this problem with a Tornado/Python app. Apparently, this can be caused by the port being interpreted as a string instead of an integer. So in my case, I needed to change my startup script to force it to be interpreted as an integer.
application = tornado.web.Application(...)
application.listen(int(port))
Are you able to enter your client ? before trying to sync the files, try to create a perforce client:
p4 client
Maybe it's not the host:port that is the issue, but other flags in the connection string that interrupt.
I personally received the exact same error, but it was a Perforce issue.
The reason is, Perforce has its own priority when it's looking for its P4USER/P4PORT/... configuration.
ENV variables ( run export )
if a P4CONFIG variable was specified somewhere it can search in a file ( like .perforce in the current/upper directory )
Problem was, even though it first search for an ENV variable - the P4CONFIG file might override it.
So my $P4PORT ENV variable had a connection string X, but the .perforce file had a connection string Y.
Removing the P4PORT from my local .perforce file - solved this issue.
in example:
$~] echo $P4PORT;
rsh:ssh -2 -q -a -x -l p4ssh perforce.mydomain.com
$~] cat .perforce
# P4PORT="rsh:ssh -q -a -x -l perforce.mydomain.com /bin/true"
P4USER="my_user"
Also remember that Perforce will search for the $P4CONFIG file ( if configured one ) in the entire directory hierarchy upwards, so even if you don't have the file in the current directory - it might be found in an upper directory, and there - you might have a $P4PORT configuration that you didn't expect..
Put trailing slash, e.g.:
http://perforce.xxx.com:1666/
Instead of:
http://perforce.xxx.com:1666
In my case I got like this error in golang language, i changed my port type from string to int and works fine