目次~
*概要 [#h3d38ba1]
**前提 [#i574e6e4]
CentOS 7に手動でVLANを定義する手順。~
CentOSのインターフェイス名を従来の形式に変更し、NetworkManagerを停止させた上で以下の操作を行うことを前提とする。~
*環境 [#nfb3bb28]
|OS|CentOS Linux release 7.2.1511 (Core) |
*設定 [#f33490ce]
**設定内容 [#m27482f3]
1つのNICに対して、3つのアドレスを付与し、内2つにはVLANを定義する。~
|Device|IP Address|VLAN|
|eth0|192.168.1.200|N/A|
|eth0.10|192.168.10.200|10|
|eth0.100|172.16.1.200|100|
VLANを付与するインターフェイスの設定ファイルは「.」で区切ってVLAN IDを付与する従来の方式が使用できる。~
**インターフェイスの設定 [#sf9f3f5e]
-ifcfg-eth0
TYPE="Ethernet"
BOOTPROTO=none
DEVICE="eth0"
ONBOOT="yes"
IPADDR=192.168.1.200
PREFIX=24
NETWORK=192.168.1.0
-ifcfg-eth0.10
TYPE="Ethernet"
BOOTPROTO=none
DEVICE="eth0.10"
ONBOOT="yes"
IPADDR=192.168.10.200
PREFIX=24
NETWORK=192.168.10.0
VLAN=yes
-ifcfg-eth0.100
TYPE="Ethernet"
BOOTPROTO=none
DEVICE="eth0.100"
ONBOOT="yes"
IPADDR=172.16.1.200
PREFIX=24
NETWORK=172.16.1.0
VLAN=yes
**有効化 [#w7cb6bd0]
ネットワークサービスを再起動する。~
systemctl restart network.service
# systemctl restart network.service
**確認 [#ifa0ee37]
設定結果の反映状況を確認する。~
ifconfig
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.200 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::ba27:ebff:fe3c:2179 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:3c:21:79 txqueuelen 1000 (Ethernet)
RX packets 32783 bytes 2597613 (2.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6051 bytes 527705 (515.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0.10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.200 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::ba27:ebff:fe3c:2179 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:3c:21:79 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 816 (816.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0.100: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.1.200 netmask 255.255.255.0 broadcast 172.16.2.255
inet6 fe80::ba27:ebff:fe3c:2179 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:3c:21:79 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 816 (816.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 4 bytes 344 (344.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 344 (344.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0