본문으로 바로가기
반응형

IPv4는 32bit 구조였으지만 IPv6sms 128 Bit구조로 이루어져 있으며 16진수로 표기하고 8개의 필드로 구성되어있으며 : 으로 구분합니다.
IPv6 주소는 64 bit를 기준으로 앞 64비트는 네트워크 주소이고, 뒤 64 bit는 호스트 주소를 나타냅니다.

 

 

본 가이드에서는 web-1 / 2 서버의 httpd 설치와 Listen port 8080 변경에 대한 내용을 작성하지 않았습니다.

httpd 설치 : dnf install -y httpd

httpd Listen Port변경 :  /etc/httpd/conf/httpd.conf

index.html 작성 : /var/www/html 

 

1. 시험환경

RHEL8.2 

KVM에 3개 VM 생성 (HAProxy, Web-1, Web-2)

HAProxy : xx.xx.xx.190

Web-1 : xx.xx.xx.191

Web-2 : xx.xx.xx.192

1 Network

 

2. HAProxy 설치

[root@haproxy ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:03:c5:49 brd ff:ff:ff:ff:ff:ff
    inet xx.xx.xx.190/24 brd 60.40.169.255 scope global noprefixroute ens3
       valid_lft forever preferred_lft forever
    inet6 fe80::7565:3b62:bdd6:6dc3/64 scope link noprefixroute
       valid_lft forever preferred_lft forever


[root@haproxy ~]# subscription-manager register
You are attempting to use a locale that is not installed.
등록 대상: subscription.rhsm.redhat.com:443/subscription
사용자 이름: hkjeon@etechsystem.co.kr
??:



[root@haproxy ~]# yum install -y haproxy


[root@haproxy ~]# cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.default

 

 

3. HAProxy 구성

IPv6에 대한 8080 바인드를 위해 *:8080 아래에 [::]:8080을 추가합니다. 

    bind *:8080
    bind [::]:8080

[root@haproxy network-scripts]# cat /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# global
#---------------------------------------------------------------------
global
    log 127.0.0.1 local2

    chroot /var/lib/haproxy
    pidfile /var/run/haproxy.pid
    maxconn 4000
    user haproxy
    group haproxy
    daemon

    stats socket /var/lib/haproxy/stats

    ssl-default-bind-ciphers PROFILE=SYSTEM
    ssl-default-server-ciphers PROFILE=SYSTEM
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
    balance roundrobin
    server static 127.0.0.1:4331 check

#===== api-server =====
frontend openshift-api-server
    bind *:8080
    bind [::]:8080
    default_backend ipv6-test
    mode tcp
    option tcplog

backend ipv6-test
    balance roundrobin
    mode tcp
    server web-1 xx.xx.xx.191:8080 check
    server web-2 xx.xx.xx.192:8080 check

    server web-1 aaaa::260:3eff:fe11:5002:8080 check
    server web-2 aaaa::260:3eff:fe11:5003:8080 check
    
    

[root@haproxy network-scripts]# systemctl restart haproxy

 

 

4. IPv6 Port 확인

tcp6 부분이 보여지는지 확인합니다.

[root@haproxy haproxy]# netstat -nlp | grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      10051/haproxy
tcp6       0      0 :::8080                 :::*                    LISTEN      10051/haproxy

 

 

5. HAProxy IPv6 IP추가

[root@haproxy network-scripts]# cat ifcfg-ens3
TYPE="Ethernet"
BOOTPROTO="none"
NAME="ens3"
DEVICE="ens3"
ONBOOT="yes"
IPV6INIT=yes
IPV6_AUTOCONF=no
IPADDR="xx.xx.xx.190"
PREFIX="24"
GATEWAY="xx.xx.xx.1"
IPV6ADDR=AAAA::260:3EFF:FE11:5001
#IPV6_DEFAULTGW=AAAA::260:3EFF:FE11:6780


[root@haproxy network-scripts]# ifdown ens3 && ifup ens3

 

6. Web-1과 Web-2 VM에 IPv6 IP추가

## Web-1
[root@web-1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens3
TYPE="Ethernet"
BOOTPROTO="none"
NAME="ens3"
DEVICE="ens3"
ONBOOT="yes"
IPV6INIT=yes
IPV6_AUTOCONF=no
IPADDR="xx.xx.xx.191"
PREFIX="24"
GATEWAY="xx.xx.xx.1"
IPV6ADDR=AAAA::260:3EFF:FE11:5002

[root@web-1 ~]# ifdown ens3 && ifup ens3



## Web-2
[root@web-2 network-scripts]# cat ifcfg-ens3
TYPE="Ethernet"
BOOTPROTO="none"
NAME="ens3"
DEVICE="ens3"
ONBOOT="yes"
IPV6INIT=yes
IPV6_AUTOCONF=no
IPADDR="xx.xx.xx.192"
PREFIX="24"
GATEWAY="xx.xx.xx.1"
IPV6ADDR=AAAA::260:3EFF:FE11:5003


[root@web-2 network-scripts]# ifdown ens3 && ifup ens3

 

 

7. HAProxy와 web-1 / web-2 서버간 IPv6 Ping 확인

HAProxy 서버에서 Web-1과 Web-2 서버간 핑 통신을 확인합니다.

RHEL8에서는 ping 명령어를 사용하거나 ping6 을 사용해도 됩니다.

 

 

 

8. HAProxy를 통한 IPv6 LB 테스트

HAProxy 서버에서 curl 명령을 통해 IPv6 LB 테스트를 수행합니다.

IPv4에서 처럼 curl로는 IPv6 curl 수행하게 되면 아래와 같은 에러가 발생합니다.

 

[root@haproxy network-scripts]# curl http://aaaa::260:3eff:fe11:5001:8080
curl: (3) IPv6 numerical address used in URL without brackets

 

따라서 방식으로 curl을 사용하여 IPv6에 대한 curl을 수행할 수 있습니다.

[root@haproxy network-scripts]# curl -g -6 'http://[aaaa::260:3eff:fe11:5001%ens3]:8080/'
Hello ~!!! Web Server# 1111
[root@haproxy network-scripts]# curl -g -6 'http://[aaaa::260:3eff:fe11:5001%ens3]:8080/'
Hello ~!!! Web Server #22222

 

 

 

728x90