0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IBM Cloud: Custom Routeを使って予約済みのアドレスを利用する方法

Last updated at Posted at 2022-06-15

1. はじめに

https://cloud.ibm.com/docs/vpc?topic=vpc-about-networking-for-vpc#reserved-ip-addresses
によると、例えば
192.168.0.0/24というsubnetをVPCで定義しても、

192.168.0.0: Network address
192.168.0.1: Gateway address
192.168.0.2: reserved by IBM
192.168.0.3: reserved by IBM for future use
192.168.0.255: Network broadcast address

というアドレスは予約済みで利用できないが、Custom Routeを利用すればこの問題を回避することが可能であるケースがある。

2. 構成

今回は、192.168.0.0/24上のIPアドレスを任意のサーバーに付与して、アクセスする方法を試してみる。
このサーバーのアドレスは10.0.0.33とする。

2-1. Custom Routeの設定

以下の構成により、192.168.0.0/24宛のパケットは10.0.0.33に到達する。

image.png

2-2. 受信側サーバーにCustom Routeで設定したアドレスを付与する

# ip addr add local 192.168.0.1/24 dev eth0 label eth0:vip1
# ip addr add local 192.168.0.2/24 dev eth0 label eth0:vip2
# ip addr add local 192.168.0.3/24 dev eth0 label eth0:vip3
# ip addr add local 192.168.0.4/24 dev eth0 label eth0:vip4
# 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:68:02:70:58 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.33/24 brd 10.0.0.255 scope global noprefixroute dynamic eth0
       valid_lft 296sec preferred_lft 296sec
    inet 192.168.0.1/24 scope global secondary eth0:vip1
       valid_lft forever preferred_lft forever
    inet 192.168.0.2/24 scope global secondary eth0:vip2
       valid_lft forever preferred_lft forever
    inet 192.168.0.3/24 scope global secondary eth0:vip3
       valid_lft forever preferred_lft forever
    inet 192.168.0.4/24 scope global secondary eth0:vip4
       valid_lft forever preferred_lft forever
    inet6 fe80::68ff:fe02:7058/64 scope link
       valid_lft forever preferred_lft forever

2-3. 受信側サーバーでIP Spoofingの有効化する

本来VPCから割り当てられていないアドレスを使ってパケットを発信する必要があるため、IP Spoofingを有効にする。
image.png

3. テスト

[root@new-syasuda-tok1-vpc1 ~]# ping -c 3 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.404 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.399 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.381 ms

--- 192.168.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.381/0.394/0.404/0.024 ms
[root@new-syasuda-tok1-vpc1 ~]# ping -c 3 192.168.0.2
PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.
64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=9.30 ms
64 bytes from 192.168.0.2: icmp_seq=2 ttl=64 time=0.423 ms
64 bytes from 192.168.0.2: icmp_seq=3 ttl=64 time=0.359 ms

--- 192.168.0.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.359/3.361/9.302/4.201 ms
[root@new-syasuda-tok1-vpc1 ~]# ping -c 3 192.168.0.3
PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
64 bytes from 192.168.0.3: icmp_seq=1 ttl=64 time=0.374 ms
64 bytes from 192.168.0.3: icmp_seq=2 ttl=64 time=0.395 ms
64 bytes from 192.168.0.3: icmp_seq=3 ttl=64 time=0.392 ms

--- 192.168.0.3 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.374/0.387/0.395/0.009 ms
[root@new-syasuda-tok1-vpc1 ~]# ping -c 3 192.168.0.4
PING 192.168.0.4 (192.168.0.4) 56(84) bytes of data.
64 bytes from 192.168.0.4: icmp_seq=1 ttl=64 time=0.483 ms
64 bytes from 192.168.0.4: icmp_seq=2 ttl=64 time=0.431 ms
64 bytes from 192.168.0.4: icmp_seq=3 ttl=64 time=0.451 ms

--- 192.168.0.4 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.431/0.455/0.483/0.021 ms
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?