wiki:TipAndDoc/VM/network

Version 1 (modified by mitty, 15 years ago) (diff)

--

VMによるネットワークテスト

network map

                      WAN
                       |
                       |
                 Windows (NAT)
                 192.168.40.1
                       |
                       |
            ((( 192.168.40.0/24 )))
             |                   |
             |                   |
        192.168.40.10     192.168.40.20
             |                   *
           <eth0>              <eth0>
      [[ubuntu-outer]]   <<centos-outer>>
           <eth1>              <eth1>
             *                   |
           10.0.0.10       10.0.0.20
                  |         |
                  |         |
                 (10.0.0.0/16)
                       |
                       |
                  10.0.0.254
                       *(10.0.0.20)
                     <eth0>
               <<ubuntu-router>>
              <eth1>        <eth2>
                |             |
          10.1.0.254         10.2.0.254
               |                      |
               |                      |
    ((((( 10.1.0.0/16 )))))          ((((( 10.2.0.0/16 )))))
    |          |      |   |             |      |  |       |
    |          |      |   |             |      |  |       |
10.1.0.10  10.1.0.20  |  10.1.0.30  10.2.0.30  |  |       |
    *          |      |   |             *      /  |       |
  <eth0>     <eth1>   |  <eth0>     <eth1>    /   |       |
 [[ubuntu-inner-AA]]  | [[ubuntu-inner-AB]]  /    |       |
                      |                     /     |       |
                      |                    /      |       |
                 10.1.0.110        10.2.0.110  10.2.0.10  10.2.0.20
                      |             |             *          |
                     <eth1>     <eth2>          <eth0>     <eth1>
                      [[centos-inner]]         [[ubuntu-inner-BB]]
                           <eth0>
                             *
                      192.168.50.110
                             |
                             |
                       192.168.50.1
                       Windows (NAT)
                             |
                             |
                            WAN
  • ((()))
    • LANセグメント
  • [[]]
    • 通常ノード
  • <<>>
    • net.ipv4.ip_forward=1 になっているノード
  • * が付いているNIC
    • デフォルトゲートウェイ

設定

centos-outer

  • centos-outer ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    BOOTPROTO=static
    IPADDR=192.168.40.20
    NETMASK=255.255.255.0
    NETWORK=192.168.40.0
    GATEWAY=192.168.40.1
    ONBOOT=yes
    
  • centos-outer ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
    DEVICE=eth1
    BOOTPROTO=static
    IPADDR=10.0.0.20
    NETMASK=255.255.0.0
    NETWORK=10.0.0.0
    ONBOOT=yes
    
  • centos-outer ~]# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.40.0    *               255.255.255.0   U     0      0        0 eth0
    10.0.0.0        *               255.255.0.0     U     0      0        0 eth1
    169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
    default         192.168.40.1    0.0.0.0         UG    0      0        0 eth0
    
  • centos-outer ~]# ip route
    192.168.40.0/24 dev eth0  proto kernel  scope link  src 192.168.40.20
    10.0.0.0/16 dev eth1  proto kernel  scope link  src 10.0.0.20
    169.254.0.0/16 dev eth1  scope link
    default via 192.168.40.1 dev eth0
    

ubuntu-outer

  • ubuntu-outer:~$ cat /etc/network/interfaces
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 192.168.40.10
            netmask 255.255.255.0
            network 192.168.40.0
    
    auto eth1
    iface eth1 inet static
            address 10.0.0.10
            netmask 255.255.0.0
            network 10.0.0.0
            gateway 10.0.0.254
    
  • ubuntu-outer:~$ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.40.0    *               255.255.255.0   U     0      0        0 eth0
    10.0.0.0        *               255.255.0.0     U     0      0        0 eth1
    default         10.0.0.254      0.0.0.0         UG    100    0        0 eth1
    
  • ubuntu-outer:~$ ip route
    192.168.40.0/24 dev eth0  proto kernel  scope link  src 192.168.40.10
    10.0.0.0/16 dev eth1  proto kernel  scope link  src 10.0.0.10
    default via 10.0.0.254 dev eth1  metric 100
    

ubuntu-router

  • ubuntu-router:~$ cat /etc/network/interfaces
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 10.0.0.254
            netmask 255.255.0.0
            network 10.0.0.0
            gateway 10.0.0.20
    
    auto eth1
    iface eth1 inet static
            address 10.1.0.254
            netmask 255.255.0.0
            network 10.1.0.0
    
    auto eth2
    iface eth2 inet static
            address 10.2.0.254
            netmask 255.255.0.0
            network 10.2.0.0
    
  • ubuntu-router:~$ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.2.0.0        *               255.255.0.0     U     0      0        0 eth2
    10.0.0.0        *               255.255.0.0     U     0      0        0 eth0
    10.1.0.0        *               255.255.0.0     U     0      0        0 eth1
    default         10.0.0.20       0.0.0.0         UG    100    0        0 eth0
    
  • ubuntu-router:~$ ip route
    10.2.0.0/16 dev eth2  proto kernel  scope link  src 10.2.0.254
    10.0.0.0/16 dev eth0  proto kernel  scope link  src 10.0.0.254
    10.1.0.0/16 dev eth1  proto kernel  scope link  src 10.1.0.254
    default via 10.0.0.20 dev eth0  metric 100
    

ubuntu-inner-AA

  • ubuntu-inner-AA:~$ cat /etc/network/interfaces
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 10.1.0.10
            netmask 255.255.0.0
            network 10.1.0.0
            gateway 10.1.0.254
    
    auto eth1
    iface eth1 inet static
            address 10.1.0.20
            netmask 255.255.0.0
            network 10.1.0.0
    
  • ubuntu-inner-AA:~$ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.1.0.0        *               255.255.0.0     U     0      0        0 eth0
    10.1.0.0        *               255.255.0.0     U     0      0        0 eth1
    default         10.1.0.254      0.0.0.0         UG    100    0        0 eth0
    
  • ubuntu-inner-AA:~$ ip route
    10.1.0.0/16 dev eth0  proto kernel  scope link  src 10.1.0.10
    10.1.0.0/16 dev eth1  proto kernel  scope link  src 10.1.0.20
    default via 10.1.0.254 dev eth0  metric 100
    

ubuntu-inner-AB

  • ubuntu-inner-AB:~$ cat /etc/network/interfaces

{{{auto lo iface lo inet loopback

auto eth0 iface eth0 inet static

address 10.1.0.30 netmask 255.255.0.0 network 10.1.0.0

auto eth1 iface eth1 inet static

address 10.2.0.30 netmask 255.255.0.0 network 10.2.0.0 gateway 10.2.0.254

}}}

  • ubuntu-inner-AB:~$ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.2.0.0        *               255.255.0.0     U     0      0        0 eth1
    10.1.0.0        *               255.255.0.0     U     0      0        0 eth0
    default         10.2.0.254      0.0.0.0         UG    100    0        0 eth1
    
  • ubuntu-inner-AB:~$ ip route
    10.2.0.0/16 dev eth1  proto kernel  scope link  src 10.2.0.30
    10.1.0.0/16 dev eth0  proto kernel  scope link  src 10.1.0.30
    default via 10.2.0.254 dev eth1  metric 100
    

ubuntu-inner-BB

  • ubuntu-inner-BB:~$ cat /etc/network/interfaces
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 10.2.0.10
            netmask 255.255.0.0
            network 10.2.0.0
            gateway 10.2.0.254
    
    auto eth1
    iface eth1 inet static
            address 10.2.0.20
            netmask 255.255.0.0
            network 10.2.0.0
    
  • ubuntu-inner-BB:~$ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.2.0.0        *               255.255.0.0     U     0      0        0 eth0
    10.2.0.0        *               255.255.0.0     U     0      0        0 eth1
    default         10.2.0.254      0.0.0.0         UG    100    0        0 eth0
    
  • ubuntu-inner-BB:~$ ip route
    10.2.0.0/16 dev eth0  proto kernel  scope link  src 10.2.0.10
    10.2.0.0/16 dev eth1  proto kernel  scope link  src 10.2.0.20
    default via 10.2.0.254 dev eth0  metric 100
    

centos-inner

  • centos-inner ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    BOOTPROTO=static
    IPADDR=192.168.50.110
    NETMASK=255.255.255.0
    NETWORK=192.168.50.0
    GATEWAY=192.168.50.1
    ONBOOT=yes
    
  • centos-inner ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
    DEVICE=eth1
    BOOTPROTO=static
    IPADDR=10.1.0.110
    NETMASK=255.255.0.0
    NETWORK=10.1.0.0
    ONBOOT=yes
    
  • centos-inner ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth2
    DEVICE=eth2
    BOOTPROTO=static
    IPADDR=10.2.0.110
    NETMASK=255.255.0.0
    NETWORK=10.2.0.0
    ONBOOT=yes
    
  • centos-inner ~]# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.50.0    *               255.255.255.0   U     0      0        0 eth0
    10.2.0.0        *               255.255.0.0     U     0      0        0 eth2
    10.1.0.0        *               255.255.0.0     U     0      0        0 eth1
    169.254.0.0     *               255.255.0.0     U     0      0        0 eth2
    default         192.168.50.1    0.0.0.0         UG    0      0        0 eth0
    
  • centos-inner ~]# ip route
    192.168.50.0/24 dev eth0  proto kernel  scope link  src 192.168.50.110
    10.2.0.0/16 dev eth2  proto kernel  scope link  src 10.2.0.110
    10.1.0.0/16 dev eth1  proto kernel  scope link  src 10.1.0.110
    169.254.0.0/16 dev eth2  scope link
    default via 192.168.50.1 dev eth0