I'm just playing with apache and i got it to work, that is i can connect to server by browsing to http://127.0.0.1 and http://192.168.1.5 i'm NOT running IPv6

Yet this is the result of netstat

$ sudo service apache2 status
 * apache2 is running
$ netstat -an | grep :80
tcp6       0      0 :::80                   :::*                    LISTEN

$ wget 127.0.0.1
--2014-06-26 01:32:15--  http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11510 (11K) [text/html]
Saving to: ‘index.html’

100%[=====================================================================================================>] 11,510      --.-K/s   in 0s      

2014-06-26 01:32:15 (161 MB/s) - ‘index.html’ saved [11510/11510]

I was expecting to see it listening on a regular TCP which it clearly does!?

Edit:

$ netstat -a | grep LISTEN
tcp        0      0 localhost:ipp           *:*                     LISTEN     
tcp        0      0 localhost:mysql         *:*                     LISTEN     
tcp6       0      0 ip6-localhost:ipp       [::]:*                  LISTEN     
tcp6       0      0 [::]:https              [::]:*                  LISTEN     
tcp6       0      0 [::]:http               [::]:*                  LISTEN     

Edit2: Why the down vote? What am i missing can someone elaborate?

  • try netstat -a | grep LISTEN and post output – Lety Jun 26 '14 at 19:23
  • Posted the results – meccooll Jun 26 '14 at 22:48
  • Tried netstat -p? – muru Jun 28 '14 at 18:39
  • the two last line are referred to apache that is listening on port 80 and 443. try muru suggestion to view process/pid. – Lety Jun 28 '14 at 21:08
  • @Letizia right but it says tcp6 in the first column and :: for ip which is IPv6, but i'm connecting to it on IPv4??? – meccooll Jun 28 '14 at 23:32
up vote 12 down vote accepted
+50

TL;DR

Apache does appear in your netstatoutput, and it is running. That's why your wget call works. However, it's bound to your IPv6 address instead of your IPv4 one. Address mapping handles the translation when necessary.

Going for the docs

There's obviously some IPv6-IPv4 fallback mechanism here. As a matter of fact, I don't use IPv6 on my local network, yet :

$ netstat -tunla | grep LISTEN | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN

It is important to note that no matter how you address your machine, it's still the same service and port in the end. The rest is mainly up to your browser and DNS resolution services. However, for more information on how Apache handles this, you may want to have a look at their documentation :

One complicating factor for Apache administrators is whether or not an IPv6 socket can handle both IPv4 connections and IPv6 connections. Handling IPv4 connections with an IPv6 socket uses IPv4-mapped IPv6 addresses, which are allowed by default on most platforms, but are disallowed by default on FreeBSD, NetBSD, and OpenBSD, in order to match the system-wide policy on those platforms. On systems where it is disallowed by default, a special configure parameter can change this behavior for Apache.

Basically, this is about handling both IPv4 and IPv6 sockets in way that will avoid most problems related to cross-platform compatibility and socket handling. As you can read, on Linux platforms like Ubuntu, this problem is solved using IPv4-mapped IPv6 addresses. The documentation also states :

If you want Apache to handle IPv4 connections only, regardless of what your platform and APR will support, specify an IPv4 address on all Listen directives.

Which would give something like this in the ports.conf file :

Listen 0.0.0.0:80 # Or...
Listen 127.0.0.1:80 # Or...
Listen 192.0.2.1:80

Resulting in one of the following netstat outputs...

$ netstat -tunla | grep LISTEN | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN 
$ netstat -tunla | grep LISTEN | grep 80
tcp        0      127.0.0.1:80              127.0.0.1:80            LISTEN
$ netstat -tunla | grep LISTEN | grep 80
tcp        0      192.0.2.1:80              192.0.2.1:80            LISTEN 

A beautiful, yet IPv6-not-ready, listener. The above setting is usually set in /etc/apache2/ports.conf (or directly in apache2.conf for older versions). The default value is Listen 80, which performs an automatic binding, i.e. conforming to the IPv6 specifications given in the documentation.

  • 1
    Huh didn't know about address mapping so i have to watch out for open ports on both IPv6 and IPv4. – meccooll Jul 1 '14 at 5:11
  • joined "askubuntu" to upvote this question and answer !!! – Prem Nov 21 '17 at 9:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.