Recently, there was an issue with a curl command that ran a script with php. The curl command would finish after a lengthy time as before it was completing within seconds.

The issue turned out to be that the command was using the IPV6 connection where in the data center the IPV6 was not active.

This was discovered with the -v option in curl.

curl -v "https://domain.com/path-to-php-script.php"
/* About to connect() to domain.com port 443 (#0)
/* Trying 2a09:2980:f0ee:a:fabe:b50c:0:2...
/* Connection timed out
/* Trying 23.17.44.888...

As you can see – the IPV6 address times out. The solution is to disable IPV6 in the network setting for the Ethernet card.

Subnet to Mask Bits conversion table
Mask CIDR Length (Mask Bits)
128.0.0.0 1
192.0.0.0 2
224.0.0.0 3
240.0.0.0 4
248.0.0.0 5
252.0.0.0 6
254.0.0.0 7
255.0.0.0 8
255.128.0.0 9
255.192.0.0 10
255.224.0.0 11
255.240.0.0 12
255.248.0.0 13
255.252.0.0 14
255.254.0.0 15
255.255.0.0 16
255.255.128.0 17
255.255.192.0 18
255.255.224.0 19
255.255.240.0 20
255.255.248.0 21
255.255.252.0 22
255.255.254.0 23
255.255.255.0 24
255.255.255.128 25
255.255.255.192 26
255.255.255.224 27
255.255.255.240 28
255.255.255.248 29
255.255.255.252 30
255.255.255.254 31
255.255.255.255 32

How to test apache.

Create 2 files:
testload.php
test.php

Create a php file testload.php that checks the existence of another file named test.php in the same directory of two CentOS 7 servers with the same hardware characteristics and load but with different MPM. One of them will use event and the other one will use prefork.

<!--?php $filename = 'test.php'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?-->

With ab, we will sent 50 (-c 50) concurrent requests at the same time and repeat the test 1000000 times

# ab -c 50 -n 100000 http://localhost/testload.php

200 simultaneous requests until 2000 requests are completed:

# ab -k -c 100 -n 2000 localhost/testload.php

Another test to localhost
PREFORK

]# ab -c 50 -n 100000 http://localhost/index.html
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
^C

Server Software:        Apache/2.4.6
Server Hostname:        localhost
Server Port:            80

Document Path:          /index.html
Document Length:        15167 bytes

Concurrency Level:      50
Time taken for tests:   3596.808 seconds
Complete requests:      34570
Failed requests:        0
Write errors:           0
Non-2xx responses:      34571
Total transferred:      537122767 bytes
HTML transferred:       524331497 bytes
Requests per second:    9.61 [#/sec] (mean)
Time per request:       5202.210 [ms] (mean)
Time per request:       104.044 [ms] (mean, across all concurrent requests)
Transfer rate:          145.83 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       3
Processing:   213 5198 241.5   5203   10154
Waiting:      174 4428 227.6   4435    9302
Total:        214 5198 241.5   5203   10154

Percentage of the requests served within a certain time (ms)
  50%   5203
  66%   5264
  75%   5302
  80%   5327
  90%   5391
  95%   5449
  98%   5532
  99%   5617
 100%  10154 (longest request)

The term hairpinning comes from the fact that the traffic comes from one source into a router or similar devices, makes a U-turn and goes back the same way it came.

Visualize this and you see something that looks like a hairpin.

Hairpin NAT is a useful technique for accessing an internal server using a public IP. Since you are using a public IP to attempt to access a server in your network, the traffic will attempt to go out to the internet. In order to reach the server, the traffic will need to be redirected to the correct location.
The issue with this article is that you need to load a website or use curl to access the website on an internal IP that is set up as NAT to a public IP.

Scenario:

Server1 – Web Server. Has a public IP 214.44.55.44 and is behind a firewall with the private IP 10.0.0.12.

When you try and load the site on this server, it does not load.
Fix: Set up hosts file to point to the private IP.

Use this information when changing the hostname in centos 7.

Ways to show the hostname

# hostname
# hostname -s
# hostname -f
# cat /etc/hostname
# hostnamectl

How to change the hostname.
In order to change or set a CentOS 7 machine hostname, use the hostnamectl command as shown in the below command excerpt.

# hostnamectl set-hostname your-new-hostname

In order to apply the new hostname, a system reboot is required, issue one of the below commands in order to reboot a CentOS 7 machine.


# init 6
# systemctl reboot
# shutdown -r now

A second method to setup a CentOS 7 machine hostname is to manually edit the /etc/hostname file

# nano /etc/hostname

When booting an Azure VM, this error:

304.863321] —[ end Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Solution: remove old linux kernels, your /boot drive is out of space.

-boot to grub and click on “Advanced options”
-Select a previous kernel (should boot fine)
login and enter command

$ df

See if your /boot directory is 100% used
Remove old linux kernels

$ sudo apt-get autoremove

Also, there may be an issue with the storage drivers (that should be built into initramfs) needed for Hyper-V / Azure.
Other Information: https://support.microsoft.com/en-us/help/4091524/how-recovery-azure-linux-vm-from-kernel-related-boot-related-issues