株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

テスト用にルータを作りたい。環境は、以下みたいな感じに。
目標はWindows10から、CentOS7-2へping飛ばしたい。

●Windows10
・ホストOS
・NIC1(物理NIC)
  IP:192.168.100.100/24
  GW:192.168.100.1
・NIC2(仮想 内部ネットワーク)
  192.168.0.1/24

●CentOS7-1
・ゲストOS
・ルータとして構築
・NIC1(仮想 内部ネットワーク)
  192.168.0.11/24
・NIC2(仮想 プライベートネットワーク)
  192.168.1.1/24
  
●CentOS7-2
・ゲストOS
・ルータとして構築
・NIC1(仮想 プライベートネットワーク)
  192.168.1.3/24

・Windows10でルーティング追加
デフォゲが物理NICに設定されているから追加しないとだめ。

C:\Windows\system32>route -p add 192.168.1.0 mask 255.255.255.0 192.168.0.11 metric 1 if 10
 OK!

C:\Windows\system32>route print
===========================================================================
インターフェイス一覧
 10...00 15 5d 0f 95 05 ......Hyper-V Virtual Ethernet Adapter

===========================================================================
固定ルート:
  ネットワーク アドレス          ネットマスク  ゲートウェイ アドレス  メトリック
      192.168.1.0    255.255.255.0      192.168.0.11       1
===========================================================================

・CentOS7-2での作業
今回の場合、ルーティングを追加する必要はないよ。
2つのNICにIPを付与している時点で、それぞれのルーティングが追加されるから。

[root@localhost ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1

ipフォワーディングを有効化

[root@localhost ~]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward = 1
[root@localhost ~]#

[root@localhost ~]# sysctl -p
net.ipv4.ip_forward = 1
[root@localhost ~]#

・Windows10からping飛ばしてみる

c:\>ping -t 192.168.1.3

192.168.1.3 に ping を送信しています 32 バイトのデータ:
192.168.1.3 からの応答: バイト数 =32 時間 =5ms TTL=63
192.168.1.3 からの応答: バイト数 =32 時間 =2ms TTL=63
192.168.1.3 からの応答: バイト数 =32 時間 =1ms TTL=63

192.168.1.3 の ping 統計:
    パケット数: 送信 = 3、受信 = 3、損失 = 0 (0% の損失)、
ラウンド トリップの概算時間 (ミリ秒):
    最小 = 1ms、最大 = 5ms、平均 = 2ms
Ctrl+C

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)