Network
1. Vlanの設定
1.1 CentOSでのVlan設定
ifcfg-eth0.100を以下の内容で作成する。
root@pc:~# vim /etc/sysconfig/network-scripts/ifcfg-eth0.100
[[VLAN]]=yes
PHYSDEV="eth0"
DEVICE="eth0.100"
NM_CONTROLLED="no"
BOOTPROTO="static"
ONBOOT=yes
IPADDR=192.168.100.1
PREFIX=24
作成後にVlanインターフェースをUpする。
root@pc:~# ifup eth0.100
- Vlan100の設定例(設定ファイル名がifcfg-ethx.yyyとならない場合)
ifcfg-vlan100の様にデバイス名をvlan idにしない場合(する場合は ifcfg-eth0.100)
VLAN作成コマンドにより対象vlanを定義する。
root@pc:~# ip link add link eth0 name vlan100 type vlan id 100
root@pc:~# vim /etc/sysconfig/network-scripts/ifcfg-vlan100
VLAN=yes
PHYSDEV="eth0"
DEVICE="vlan100"
NM_CONTROLLED="no"
BOOTPROTO="static"
ONBOOT=yes
IPADDR=192.168.100.1
PREFIX=24
作成後にVlanインターフェースをUpする。
root@pc:~# ifup vlan100
1.2 UbuntuでのVlan設定
以下のpre-upはvlanインターフェースが自動で作られないため、苦肉の策でeth0立ち上がり前に作成するように追加
eth0ダウン時はvlanインターフェースを削除するようにpost-downで指定している。
(他にもっと良いやり方あるかも・・・)
user@pc:~# sudo vim /etc/network/interfaces
auto eth0
iface eth0 inet manual
pre-up modprobe 8021q
pre-up ip link set $IFACE up
pre-up ip link add link $IFACE name eth0.10 type vlan id 10
post-down ip link del eth0.10
post-down ip link set $IFACE down
auto eth0.10
iface eth0.10 inet static
address 192.168.10.1
netmask 255.255.255.0
gateway 192.168.10.254
dns-nameserver 192.168.1.1
vlan-raw-device eth0
2. Routing
2.1 CentOSでのRouting設定
root@pc:~# vim /etc/sysconfig/network-scripts/route-eth0
192.168.0.0/16 via 192.168.255.222 dev eth0.1000
・インターフェース番号の修正(eth0, eth1とかの番号)
3. interface number (udev)
eth0等のインターフェースの番号はシステム側で認識した順番に割り振られる。
設定ファイル: /etc/udev/rules.d/70-persistent-net.rules
root@pc:~# cat /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x14e4:0x16fd (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# USB device 0x0b95:0x772b (usb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
最終更新:2014年10月26日 22:19