Wednesday, September 10, 2014

How To Set Squid 3 Prefer IPv4 Network

If you have Squid 3 server and your server connected to IPv6 network, Squid 3 will prefer to access IPv6 as default. When the IPv6 network is unreachable, it will tried to access the IPv4 address.

To make Squid 3 prefer IPv4 instead of IPv6, just put these lines in squid.conf:

dns_v4_first on

This configuration line controls whether IPv4 or IPv6 connection is attempted first when contacting servers and peers. Then, restart squid 3 service, or, if you want to reload configuration seamlessly, type command:

squid3 –k reconfigure

Squid will still perform both IPv6 and IPv4 DNS lookups before connecting to the destination server.

Tuesday, September 9, 2014

How to Make Ubuntu Prefer A (IPv4) DNS Lookup Over AAAA (IPv6)

I have Ubuntu server with both IPv6 and IPv4. IPV6 queries made before IPV4 and they where wasting resources, and also there is still no route to some network. After read from some web resources, I got that  it's the standard to prioritize IPv6 over IPv4.

I did changed my /etc/gai.conf (gai stands for getaddrinfo, the standard system call for resolving host names). For sites which prefer IPv4 connections change the last line to:

precedence ::ffff:0:0/96 100

And then, my Ubuntu server query A records (IPv4) before AAAA records (IPv6) when access domains.

Monday, September 8, 2014

How to Set Unifi DHCP Option 43 on MikroTik

We installed Unifi Pro AP in our client’s office to provide wireless access to employees. The network diagram as follow (I’ve changed the configuration to fake IP address because of our client privacy and another security reason). The Unifi Controller in this configuration have public IP address that can accessed anywhere in the world that have internet connection.

unifi_pro_network

To make Unifi Pro access point can adopted by Unifi Controller, I make DHCP in MikroTik Cloud Switch series, with add DHCP option code 43 using MikroTIk Terminal. Unifi introduced the usage of DHCP Option 43 which is used to provide clients and devices on a network the ability to locate the Unifi Controller.

Option 43 value in MikroTik DHCP will be "0x0104" + the HEX of the IP, for example in this network 128.199.238.236 converted to 80C7EEEC. Just search “Convert IP to Hexadecimal IP” and you will find so may converter tools in the Internet. After DHCP in MikroTik is set and computer that use DHCP can access the Unifi Controller port 8080 (in this example is “http://128.199.238.236:8080/inform”), type command in MikroTik Terminal to add DHCP option 43:

/ip dhcp-server option add code=43 name=unifi value=0x0104080C7EEEC
/ip dhcp-server network set 0 dhcp-option=unifi

After turn on the system, Unifi Pro AP will be shown in the Unifi Controller automatically. Unfortunately my configuration was not working. I tried more than half day just to figured out what happen. Then I just reset the Unifi Pro AP by push reset button and then it works. The problem was (maybe) Unifi AP adopted (tested by supplier) before it arrived to my client’s office. New version of Unifi Controller will not detect AP that has adopted by another Controller.