Last active
March 27, 2019 13:13
-
-
Save kitak/5974526 to your computer and use it in GitHub Desktop.
KVS導入(ダイレクトルーティング)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lb001.kitak.pbでの操作 | |
sudo yum install ipvsadm | |
sudo chkconfig --add ipvsadm | |
sudo chkconfig ipvsadm on | |
sudo su - -c 'echo "1" > /proc/sys/net/ipv4/ip_forward' | |
sudo ifconfig eth0:0 192.168.46.30 netmask 255.255.255.0 | |
sudo vi /etc/sysconfig/network-scripts/ifconfig-eth0 #次回起動時も有効にする | |
sudo ipvsadm -A -t 192.168.46.30:80 -s rr # 転送元のIPアドレス、ポート | |
sudo ipvsadm -a -t 192.168.46.30:80 -r 192.168.46.83:80 -g # 転送先のIPアドレス、ポート | |
sudo ipvsadm -Ln # 確認 | |
sudo sudo /etc/init.d/ipvsadm save # 保存 | |
## /etc/sysconfig/network-scripts/ifconfig-eth0 | |
192.168.46.30が仮想IPアドレス | |
``` | |
TYPE="Ethernet" | |
DEVICE=eth0:0 | |
BOOTPROTO=none | |
NETMASK=255.255.255.255 | |
IPADDR=192.168.46.30 | |
USERCTL=no | |
IPV6INIT=no | |
ONPARENT=yes | |
PEERDNS=yes | |
NAME=eth0:0 | |
ONBOOT=yes | |
``` | |
# app.kitak.pbでの操作 | |
sudo vi /etc/sysctl.conf | |
sudo ifconfig lo:0 192.168.46.30 netmask 255.255.255.255 | |
sudo vi /etc/sysconfig/network-scripts/ifcfg-lo:0 | |
## 動作確認 | |
ブラウザからアクセスしたらレスポンスを返してくれないので | |
proxy上からtcpdumpで確認。パケットは届いているけどインターフェイスがないので捨てられていた | |
→ ダミーインターフェイスの作成 | |
sudo tcpdump -n -i eth0 port 80 | |
## /etc/sysconfig/network-scripts/ifcfg-lo:0 | |
``` | |
DEVICE=lo:0 | |
IPADDR=192.168.46.30 | |
NETMASK=255.255.255.255 | |
ONBOOT=yes | |
``` | |
## /etc/sysctl.conf | |
eth0からARPリクエストを受け取ったときeth0インターフェイスに設定されているアドレスの情報だけを返す。 | |
eth0からARPリクエストを送信するとき、ARPリクエストの送信元アドレスとしてeth0インターフェイスに設定されているアドレスを使うようにする。 | |
``` | |
net.ipv4.conf.all.arp_ignore=1 | |
net.ipb4.conf.eth0.arp_ignore=1 | |
net.ipv4.conf.all.arp_announce=2 | |
net.ipv4.conf.eth0.arp_announce=2 | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment