How do you get the hostname of the one who is connected to the same network as i am.
Example i am at 192.168.1.16
other is at 192.168.1.15
how do i get to know his hostname with python or any command that would help?
You can try with:
nslookup IP_ADDRESS
It should show you a field name that contain the hostname.
There's also a specific command, but I don't know if it's included in every distributions:
resolveip IP_ADDRESS
Give it a try. It also has a -s option that gives you the hostname and nothing else, very useful if you need to retrieve it and store it in a variable.
resolveip -s IP_ADDRESS
Related
I need to have additional instance for our production server.
Is it possible?
Where to begin?
Using Postgresql 9.1 on Windows Server
If you already have the binaries, then adding a second instance ("cluster") is done by running initdb and then registering that new instance as a Windows service.
(I will not prefix the name of the executables with the path they are stored in. You need to either add the bin directory of the Postgres installation to your system wide PATH, use fully qualified names, or simply change into the bin directory to make it the current directory)
To do that, open a command line (cmd.exe) and use initdb to create the instance:
initdb -D c:\Data\PostgresInstance2 -W -A md5
-W makes initdb prompt you for the name and password to be used as the superuser of that instance - make sure you remember the username and passwords you have given. -D specifies where the cluster should be created. Do NOT create that under c:\Program Files.
Once the instance (cluster) is initialized edit c:\Data\PostgresInstance2\postgresql.conf to use a different port, e.g. port = 5433. If the instance should be reachable from the outside you also need to adjust listen_addresses.
You can check if everything works by manually starting the new instance:
pg_ctl start -D c:\Data\PostgresInstance2
Once you have change the port (and adjusted other configuration parameters) you can create a Windows service for the new cluster:
pg_ctl register -N postgres2 -D c:\Data\PostgresInstance2
The service will execute with the "Local Network Account", so you have to make sure the privileges on the data directory are setup properly.
#NewSheriff
Your start command for your second server needs to use the port you specified in config
e.g. if using port 5433 instead of port 5432
then adding:
-o "-p 5433"
to the end of your start-up command should get past the error message you mentioned
This one is really starting to stump me. I'm running Ubuntu 12.04 and am trying to connect to a box running MS SQL server 2012. First I'll provide some information on my setup:
My freetds.conf:
[EXNAME]
host = IP
port = 1433
tds version = 7.0
client charset = UTF-8
After setting up my freetds.conf I first test my connection with tsql which produced the expected (and welcomed) prompt:
...
using default charset "UTF-8"
1>
So my FreeTDS setup appears to be working ok. Next I setup odbc.ini and obdcinst.ini:
odbc.ini:
[EXNAME]
Driver = FreeTDS
ServerName = EXNAME
UID = Me
PWD = Pass
odbcinst.ini:
[FreeTDS]
Description = FreeTDS Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount = 1
Following this setup I run osql to check. It outputs all the expected responses, it is able to find the drivers and the correct paragraphs in ondcb.ini for example:
[EXNAME] found in /etc/odbc.ini
found this section:
[EXNAME]
Driver = FreeTDS
ServerName = EXNAME
UID = Me
PWD = Pass
looking for driver for DSN [EXNAME] in /etc/odbc.ini
found driver line: " Driver = FreeTDS"
And so on until:
DSN [EXNAME] has servername "" (from /etc/odbc.ini)
osql does not seem to be detecting the servername in odbc.ini.
Following this check I am able to connect via isql but I cannot run any SQL commands. I receive the following error:
SQL> SELECT name FROM master..sysdatabases;
[37000][unixODBC][FreeTDS][SQL Server]Could not find stored procedure 'SELECT'.
[ISQL]ERROR: Could not SQLExecute
What I've tried:
A.) Just about every configuration and naming convention one could think of across freetds.conf and both .ini files. Post changes I perform the same tests above and arrive at the same result
B.) Reproducing the error outside of isql. ROBC given me exactly the same error. Of course, this is expected but I figured why not
C.) SQL variants besides MS SQL Server. I figured just in case someone was mis-informing me I tried some MySQL commands there as well. This could be a SQL problem but I'm ot sure.
D.) The closest I've come to finding a similar error (well result I guess) to what osql spit out is here. As suggested in the last post, the problem, at least in so far as it relates to osql's response might relate to awk. As suggested I test awk by making a variable and trying to parse out the servername:
$ SERVER_LINE='ServerName = SERVER'
$ echo ${SERVER_LINE} | awk -F '=[[:space:]]*' '{print $2}'
This should result in SERVER but instead I get "".
That's all I have. In summary OSQL cannot seem to find the servername in odbc.ini and this may or may not result in me not being able to execute any commands from ISQL or ROBC. I'm beginning to suspect that these problems are disjoint but any help would be GREATLY appreciated.
EDIT:7/31/2014
Got this all working. There were some other issues going on in addition to what I highlighted. I ended up having to set up a similar connection on both a Mac and Linux box. Here are the instructions for both:
http://www.joecjr.com/2014/07/27/install-and-use-freetds-unixodbc-and-rodbc-or-pyodbc/
It took me a LONG time to properly configure unixODBC with TDS, but for what it's worth, this set of instructions was my saving grace and what finally allowed me to get it working:
http://www.unixodbc.org/doc/FreeTDS.html
Pay particular attention to the second that references this command:
odbcinst -i -s -f tds.datasource.template
It's where my biggest problem resided. What happened was I was doing this as root (which is fine), but if you read carefully it indicates that every user that uses the driver has to run this command to 'register' the connection for their userid. Once I ran the same command under each other user, everything worked fine (since my actual code doesn't run as root).
One other thought... a quick and easy test to see if the connection is actually working with TDS (even before you try the ODBC piece) is to run bcp and export a really small table.
Try something like this, just to rule out the TDS install being the issue.
freebcp <database>.dbo.<tablename> out $HOME/foo.out -c -t '|' \
-S <hostname>:<port> -U <userid> -P <password>
It's a shame Microsoft and Unix don't play nicer together.
I have just installed Apache 2.2.17, and I am using it for the first time.
Now when I try to start the server using the command service httpd start it gives me the message:
httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
Now I think I have to set ServerName and the IP address as I search through Google. But I don't know in which file I have to set.
How can I fix this problem?
sudo vim /etc/apache2/httpd.conf
Insert the following line at the httpd.conf: ServerName localhost
Just restart the Apache: sudo /etc/init.d/apache2 restart
Yes, you should set ServerName:
http://wiki.apache.org/httpd/CouldNotDetermineServerName
http://httpd.apache.org/docs/current/mod/core.html#servername
You can find information on the layouts used by the various httpd distributions here:
http://wiki.apache.org/httpd/DistrosDefaultLayout
In your case the file to edit is /etc/httpd/conf/httpd.conf
I was NOT getting the ServerName wrong. Inside your VirtualHost configuration that is causing this warning message, it is the generic one near the top of your httpd.conf which is by default commented out.
Change
#ServerName www.example.com:80
to:
ServerName 127.0.0.1:80
Under Debian Squeeze;
Edit Apache2 conf file : vim /etc/apache2/apache2.conf
Insert the following line at the apache2.conf: ServerName localhost
Restart Apache2: apache2ctl restart or /etc/init.d/apache2 restart
Should work fine (it did solve the problem in my case)
tks noodl for the link on the different layouts. :)
sudo nano /etc/apache2/httpd.conf
search for a text ServerName in nano editor <Ctrl + W>
Insert the following line at the httpd.conf: ServerName localhost
Just restart the Apache: sudo /usr/sbin/apachectl restart
Another option is to ensure that the full qualified host name (FQDN) is listed in /etc/hosts.
This worked for me on Ubuntu v11.10 without having to change the default Apache configuration.
" To solve this problem You need set ServerName.
1: $ vim /etc/apache2/conf.d/name
For example set add ServerName localhost or any other name:
2: ServerName localhost
Restart Apache 2
3: $ service apache restart
For this example I use Ubuntu 11.10.1.125"
FQDN means the resolved name over DNS. It should be like "server-name.search-domain".
The warning you get just provides a notice that httpd can not find a FQDN, so it might not work right to handle a name-based virtual host. So make sure the expected FQDN is registered in your DNS server, or manually add the entry in /etc/hosts which is prior to hitting DNS.
If you are using windows there is something different sort of situation
First open c:/apache24/conf/httpd.conf.
The Apache folder is enough not specifically above path
After that you have to configure httpd.conf file.
Just after few lines there is pattern like:
#Listen _____________:80
Listen 80
Here You have to change for the localhost.
You have to enter ipv4 address for that you can open localhost.
Refer this video link and after that just bit more.
Change your environment variables:
In which you have to enter path:
c:apache24/bin
and
same in the SYSTEM variables
If any query feel free to ask.
Two things seemed to do it for me:
Put all aliases for 127.0.0.1 in /etc/hosts in a single line (e.g. 127.0.0.1 localhost mysite.local myothersite.local
Set ServerName in my httpd.conf to 0.0.0.0 (localhost or 127.0.0.1 didn't work for me)
Editing /etc/hosts got rid of long response times and setting the ServerName got rid of OP's warning for me.
who are still couldnt resolve the problem and using mac then follow this
1.goto the root folder /
cd usr/local/etc/apache2/2.4
3.sudo nano httpd.conf
4.change #servername to ServerName 127.0.0.1:8080 press ctrl+o,+return+ctrl x
5.then restart the server apachectl restart
If you are using windows, remove comment on these lines and set them as:
Line 227 : ServerName 127.0.0.1:80
Line 235 : AllowOverride all
Line 236 : Require all granted
Worked for me!
Here's my two cents. Maybe it's useful for future readers.
I ran into this problem when using Apache within a Docker container. When I started a container from an image of the Apache webserver, this message appeared when I started it with docker run -it -p 80:80 my-apache-container.
However, after starting the container in detached mode, using docker run -d -p 80:80 my-apache-container, I was able to connect through the browser.
I am using ubuntu 22.04
I installed the apache2 at the location '/usr/local/apache2'
I just edited the '/usr/local/apache2/conf/httpd.conf' file.
run the following commands
cd /usr/local/apache2/conf
sudo nano httpd.conf
find this comment
#ServerName www.example.com:80, in my case it is at line 197
after that add this
ServerName localhost
don't modify anything else in this file!
Thank you!
How do you test to see if your program is working and able to connect with server? I tried stackoverflow server's ip through port 40 and it fails after a min at connect().
test.exe 64.34.119.12 echo 40
Program arguments take a syntax: <Server IP> <Echo Word> [<Echo Port>]
Also, can you test without having to connect to internet?
You should be able to connect to your own echo server on 127.0.0.1:7 if it is running, or get a 'connection refused' (ECONN) if it isn't running. Either would show that your code is OK actually.
As for testing without having to connect to the internet...
I'd download netcat for windows.
NetCat download
Extract the tool, and run:
nc.exe -v -l -p [port]
If you do that, it opens up a "server" and you can connect to it using your application; just point the IP address to 127.0.0.1!
I'm using Apache2, and when reloading/restarting the server I get this warning:
apache2: Could not reliably determine the server's fully qualified domain name, using (my FQDN) for ServerName
Everything works fine, but I'm trying to figure out what's causing the error. I'm grabbing the source to see if can find it, but since my C's not very good....
Some notes:
If I change the system hostname, Apache uses the new hostname
I have a ServerName set; it's the same as the hostname
I have a static, unique IP - dig (hostname) returns (my ip), dig -x (my ip) returns (hostname)
My hosts file is correct
Versions:
Apache/2.2.9
Linux 2.6.24-23-xen x86_64
Description: Debian GNU/Linux 5.0 (lenny)
Any ideas?
Are you sure you have a ServerName directive with the proper value - outside any <VirtualHost> blocks? (You also need a ServerName inside each <VirtualHost> block, of course)
When Apache gives out that error message, usually it means that it's not finding a ServerName for the server as a whole. If you do have that directive set properly, I can't imagine why Apache would still be complaining...
On Debian, the hostname is set at startup thanks to the script /etc/init.d/hostname.sh which uses the file /etc/hostname. We can use this file to update the computer hostname and its FQDN (fully qualified domain name).
If ServerName in your vhost is my-computer.my-domain.ext make sure to copy the exact name in /etc/hosts
Caution: in the /etc/hosts file, the hostname and FQDN order must be respected.
First the fqdn then the hostname and localhost at the end.
~$ echo "my-computer" > /etc/hostname
~$ echo "127.0.0.1 my-computer.my-domain.ext my-computer localhost" > /etc/hosts
~$ /etc/init.d/hostname.sh
You can check the change with the following lines:
~$ hostname
my-computer
~$ hostname --fqdn
my-computer.my-domain.ext
The old hostname may still be present in the command line prompt. Just logoff then login to make it disappear.
For further information about setting hostname and FQDN on debian (which also prevents the warning) check this: http://movealong.org/hostname.html