I'm checking for comprehension on a homework question for my class. I looked over the man pages for ping and the -t flag didn't have a lot of info on it so I had to infer quite a bit. If someone could verify that my understanding is correct, and perhaps point me to a resource that explains -t flag better than the man pages, I'd appreciate it.
The question:
Write a bash command line that will verify that no more than two network devices are used to pass messages from the syccuxas01.pcc.edu server to the www.pcc.edu server. Use ping with the -t option and see the TTL Details section of man ping.
ping -t 2 www.pcc.edu
My understanding of what that command means and thoughts: The question is poorly worded as "network devices" would be more accurately described as hops. Hops are the steps that a packet of information takes to get to the server you want to send it to, much like if you're going on a car trip, you'll drive through other towns along the way to your destination.
So if we ping the TTL (time to live, which is very dramatic sounding!) [ aka -t ] twice, we're able to get results, which means that there are 2 "hops" to get to www.pcc.edu from the server we access through Putty. TTL from what I understand means how many hops the ping will try to use to send a packet. So ping -t 1 www.pcc.edu will fail. ping -t 3 www.pcc.edu will succeed, but it's using 3 hops, which is not what we want to solve the problem.
Related
I'm trying to scan list of IP addresses using below command
nmap -v -n -sP -iL <IP-list-file.txt>
here I'm looking retry option with nmap command for the failed probe retransmission. Above command will do a single ICMP probe for each IP/hosts. Even I tried with --max-retries no result. So I'm looking a similiar option like { ping -c<2> IP > along with this nmap.
Even tried "-A -T5" no result
Note:- My purpose is to check only whether the host/IP is alive or dead that's it. Preferably nmap utility.
Nmap uses a lot of different methods for host discovery. The options that you used will do one of two things depending on whether you have root privileges:
If you do run Nmap as root, it will send four probes: ICMP Echo Request, TCP SYN to port 443, TCP ACK to port 80, and ICMP Timestamp Request. Only if all four fail to get a response will it mark the target as down.
If you do not run Nmap as root, it will attempt to make a TCP connection to port 80 and port 443. If both of these time out, it will mark the target as down.
So this method is already more robust than simply using /bin/ping. Nmap also retries probes a certain number of times depending on how reliable the network seems. For host discovery, this starts out at 2 retransmits per probe. There doesn't really seem to be a way to increase this without Nmap detecting network problems, so the best way to increase confidence in a "down" determination is to add more host discovery probes using the various -P* options.
The -A and -T5 options will not help at all. -A turns on extra features, none of which will run if the target is considered down, and -T5 simply tells Nmap to assume a very fast and reliable network. It will never retransmit more than 2 times, and will time out probes very quickly. This is almost certainly the opposite of what you want.
Apologies if this is in some way a duplicate - I couldn't find anything that covered this (at least in a way that I could understand made it similar).
Here's a basic diagram of my connections:
Laptop => SSH server 1 => SSH server 2 => MySQL (MariaDB)
I can use terminal to jump across to server 2 as per the usual methods:
ssh -t user#server1 ssh -p99 user#server2
Then, in the terminal, I can mysql -uroot -p as normal.
(connections amended to remove details, of course)
I have attempted a few different things to try and get a direct connection in DBeaver, but I can't seem to make it work with that extra ssh connection (inssheption - it's new to me). I've found, and have been playing with, Gnome Connection Manager to try and make this happen - I'm used to Win tools like Penguinet, which isn't available on Linux, but it does look to be capable.
I'm probably just out of my depth, but I am thinking that this should be simple - but I just can't get the hang of how to get this going.
I'm expecting that at some point I'll be able to connect to 127.0.0.1:1234 in DBeaver (SQL GUI), but I'm just struggling to make that happen.
Does anyone have a moment to advise the best method to daisy-chain the connections together?
Use port forwarding with SSH to bring remote port to your local machine.
ssh -L 1234:server1:1234 -t user#server1 ssh -L 1234:server2:1234 -p99 user#server2
Now you can connect to localhost:1234 and your connection will be forwarded to server2:1234. Just make sure that port 1234 on server1 and localhost are not in use.
I'm setting up a PrestaShop installation on a development server which is a GCE instance and using Cloud SQL as a database server. Everything works just fine except one thing: whenever there is a long period of inactivity on the site, the first page load after that always gives me this error:
Link to database cannot be established: SQLSTATE[HY000] [2003]
If I refresh the page the error is gone and never appears again until I stop using the site for an hour or so. It almost looks like database instance is going into sleep mode or something like that.
The reason I mentioned Prestashop is the fact that I never get this error when using Adminer or connecting to the database from mysql console client.
With the per use billing model, instances are spun down after a 15 minute timeout to save you money. They then take a few seconds to be spun up when next accessed. It may be the Prestashop is timing out on these first requests (though I have no experience with that application).
Try changing your instance to a package billing, which has a 12 hour timeout, to see if this helps
https://developers.google.com/cloud-sql/faq#how_usage_calculated
According to GCE documentation,
Once a connection has been established with an instance, traffic is permitted in both directions over that connection, until the connection times out after 10 minutes of inactivity
I suspect that might be the cause. To get around it, you can try to lower the tcp keepalive time.
Refer here: https://cloud.google.com/sql/docs/compute-engine-access
To keep long-lived unused connections alive, you can set the TCP keepalive. The following commands set the TCP keepalive value to one minute and make the configuration permanent across instance reboots.
# Display the current tcp_keepalive_time value.
$ cat /proc/sys/net/ipv4/tcp_keepalive_time
# Set tcp_keepalive_time to 60 seconds and make it permanent across reboots.
$ echo 'net.ipv4.tcp_keepalive_time = 60' | sudo tee -a /etc/sysctl.conf
# Apply the change.
$ sudo /sbin/sysctl --load=/etc/sysctl.conf
# Display the tcp_keepalive_time value to verify the change was applied.
$ cat /proc/sys/net/ipv4/tcp_keepalive_time
So anyways, I'm working on a small PHP website/script, and as one of the features I'd like to be able to run a Ping Test on the current domain the PHP script is running on. I don't know much about Ping test (well, I know what they do, I just don't know how to run them in PHP) Please let me know how to do it and get same result as : http://www.ipfingerprints.com/ping.php
There is no built-in method to running a ping test in PHP, you must use exec to run the command.
exec('ping -n 4 $ip', $output, $retval);
If you want to send ICMP packets in php you can take a look at this Native-PHP ICMP ping implementation, but I didn't test it.
I'm curious if it is possible to map a UNIX socket on to an INET socket. The situation is simply that I'd like to connect to a MySQL server. Unfortunately it has INET sockets disabled and therefore I can only connect with UNIX sockets. The tools I'm using/writing have to connect on an INET socket, so I'm trying to see if I can map one on to the other.
It took a fair amount of searching but I did find socat, which purportedly does what I'm looking for. I was wondering if anyone has any suggestions on how to accomplish this. The command-line I've been using (with partial success) is:
socat -v UNIX-CONNECT:/var/lib/mysql/mysql.sock TCP-LISTEN:6666,reuseaddr
Now I can make connections and talk to the server. Unfortunately any attempts at making multiple connections fail as I need to use the fork option but this option seems to render the connections nonfunctional.
I know I can tackle the issue with Perl (my preferred language), but I'd rather avoid writing the entire implementation myself. I familiar with the IO::Socket libraries, I am simply hoping anyone has experience doing this sort of thing. Open to suggestions/ideas.
Thanks.
Reverse the order of your arguments to socat, and it works.
socat -v tcp-l:6666,reuseaddr,fork unix:/var/lib/mysql/mysql.sock
This instructs socat to
Listen on TCP port 6666 (with SO_REUSEADDR)
Wait to accept a connection
When a connection is made, fork. In the child, continue the steps below. In the parent, go to 2.
Open a UNIX domain connection to the /var/lib/mysql/mysql.sock socket.
Transfer data between the two endpoints, then exit.
Writing it the other way around
socat -v unix:/var/lib/mysql/mysql.sock tcp-l:6666,reuseaddr,fork
doesn't work, because this instructs socat to
Open a UNIX domain connection to the /var/lib/mysql/mysql.sock socket.
Listen on TCP port 6666 (with SO_REUSEADDR)
Wait to accept a connection
When a connection is made, spawn a worker child to transfer data between the two addresses.
The parent continues to accept connections on the second address, but no longer has the first address available: it was given to the first child. So nothing useful can be done from this point on.
Yes, you can do this in Perl.
Look at perlipc, IO::Select, IO::Socket and Beej's Guide to Network Programming.
You might want to consider doing it in POE - it's asynchronous library for dealing with events, so it looks like great for the task.
It is not 100% relevant, but I use POE to write proxy between stateless protocol (HTTP) and statefull protocol (telnet session, and more specifically - MUD session), and it was rather simple - You can check the code in here: http://www.depesz.com/index.php/2009/04/08/learning-poe-http-2-mud-proxy/.
In the comments somebody also suggested Coro/AnyEvent - I haven't played with it yet, but you might want to check it.