Linux VLAN Priority CoS config
11/24/2015, 16:54 - Network
With Ubuntu 15.10
apt-get install vlan

/etc/udev/rules.d/70-persistent-net.rules

# USB device 0x:0x (ax88179_178a)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:05:1b:a3:12:ce", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth10"


/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto p2p1
#iface p2p1 inet dhcp
#
# Change biosdevname back to eth
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
#
# address 192.168.7.200
# netmask 255.255.0.0
# gateway 192.168.1.201
#
address 172.22.10.254
netmask 255.255.255.0
gateway 172.22.10.1
#
dns-nameserver 8.8.8.8
dns-nameserver 8.8.4.4
txq 30000
#
# Wireless Client
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wireless_mode managed
wireless_txpower auto
#
pre-up wpa_supplicant -B -Dwext -iwlan0 \
-c/etc/wpa_supplicant/wpa_supplicant.conf
post-down killall -q wpa_supplicant
#
dns-nameserver 8.8.8.8
dns-nameserver 8.8.4.4
#
# Wireless AP
#auto wlan0
#iface wlan0 inet static
# hostapd /etc/hostapd/hostapd.conf
# wireless_txpower auto
# address 172.22.2.254
# netmask 255.255.255.0
#
#
auto eth10
allow-hotplug eth10
txq 10000
#
auto eth10.10
iface eth10.10 inet static
#
vlan-egress-map 0:3 4:3 2:1
vlan-ingress-map 0:5 1:6 2:7
address 10.10.10.3
netmask 255.255.255.0
#
dns-nameserver 8.8.8.8
dns-nameserver 8.8.4.4
txq 5000
#
auto eth10.20
iface eth10.20 inet static
#
vlan-egress-map 0:3 4:3 2:1
vlan-ingress-map 0:5 1:6 2:7
address 10.10.20.3
netmask 255.255.255.0
#
dns-nameserver 8.8.8.8
dns-nameserver 8.8.4.4
txq 5000
#
auto eth10.30
iface eth10.30 inet static
#
vlan-egress-map 0:3 4:3 2:1
vlan-ingress-map 0:5 1:6 2:7
address 10.10.30.3
netmask 255.255.255.0
#
dns-nameserver 8.8.8.8
dns-nameserver 8.8.4.4
txq 5000
#

/etc/network/if-up.d/vlan

#!/bin/sh

# Most of this stuff is to enable vlans

case "$IFACE" in
# Ignore any alias (#272891) which uses <interface>:<alabel>
*:*)
exit 0
;;
vlan0*)
vconfig set_name_type VLAN_PLUS_VID
VLANID=`echo $IFACE|sed "s/vlan0*//"`
;;
vlan*)
vconfig set_name_type VLAN_PLUS_VID_NO_PAD
VLANID=`echo $IFACE|sed "s/vlan0*//"`
;;
eth*.0*|bond*.0*|wlan*.0*|em*.0*|p[0-9]*.0*)
vconfig set_name_type DEV_PLUS_VID
VLANID=`echo $IFACE|sed "s/eth[0-9][0-9]*\.0*//g;s/bond[0-9][0-9]*\.0*//g;s/wlan[0-9][0-9]*\.0*//g;s/em[0-9][0-9]*\.0*//g;s/p[0-9][0-9]*\(p[0-9][0-9]*\)\?\(_[0-9][0-9]*\)\?\.0*//g"`
IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/\(eth[0-9][0-9]*\)\..*/\1/;s/\(bond[0-9][0-9]*\)\..*/\1/;s/\(wlan[0-9][0-9]*\)\..*/\1/;s/\(em[0-9][0-9]*\)\..*/\1/;s/\(p[0-9][0-9]*\(p[0-9][0-9]*\)\?\(_[0-9][0-9]*\)\?\)\..*/\1/"`
;;
eth*.*|bond*.*|wlan*.*|em*.*|p[0-9]*.*)
vconfig set_name_type DEV_PLUS_VID_NO_PAD
VLANID=`echo $IFACE|sed "s/eth[0-9][0-9]*\.0*//g;s/bond[0-9][0-9]*\.0*//g;s/wlan[0-9][0-9]*\.0*//g;s/em[0-9][0-9]*\.0*//g;s/p[0-9][0-9]*\(p[0-9][0-9]*\)\?\(_[0-9][0-9]*\)\?\.0*//g"`
IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/\(eth[0-9][0-9]*\)\..*/\1/;s/\(bond[0-9][0-9]*\)\..*/\1/;s/\(wlan[0-9][0-9]*\)\..*/\1/;s/\(em[0-9][0-9]*\)\..*/\1/;s/\(p[0-9][0-9]*\(p[0-9][0-9]*\)\?\(_[0-9][0-9]*\)\?\)\..*/\1/"`
;;
*.0*)
# Silently ignore interfaces which we do not (know how to) support
[ -z "$IF_VLAN_RAW_DEVICE" ] && exit 0
vconfig set_name_type DEV_PLUS_VID
VLANID=`echo $IFACE|sed "s/[^.]*\.0*//g"`
;;
*.*)
# Silently ignore interfaces which we do not (know how to) support
[ -z "$IF_VLAN_RAW_DEVICE" ] && exit 0
vconfig set_name_type DEV_PLUS_VID_NO_PAD
VLANID=`echo $IFACE|sed "s/[^.]*\.0*//g"`
;;

*)
exit 0
;;
esac

if [ -n "$IF_VLAN_RAW_DEVICE" ] && [ -d /sys/class/net/$IFACE ]; then
if [ ! -x /sbin/vconfig ]; then
exit 0
fi
if [ -n "$IF_VLAN_EGRESS_MAP" ]; then
for i in $IF_VLAN_EGRESS_MAP ; do
vconfig set_egress_map $IFACE `echo $i|cut -d: -f1` `echo $i|cut -d: -f2`
done
fi
if [ -n "$IF_VLAN_INGRESS_MAP" ]; then
for i in $IF_VLAN_INGRESS_MAP ; do
vconfig set_ingress_map $IFACE `echo $i|cut -d: -f1` `echo $i|cut -d: -f2`
done
fi
fi
#


/etc/network/if-up.d/ifqueue

#!/bin/sh
if [ -d "/sys/class/net/$IFACE" ]; then
TXQ=`expr $IF_TXQ + 0`
if [ -n "$IF_TXQ" ] && [ "$TXQ" -gt 0 ]; then
# ifconfig $IFACE txqueuelen $TXQ
ip link set txqueuelen $TXQ dev $IFACE
fi
fi
#


ip link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 30000
link/ether 08:62:66:c7:ba:b0 brd ff:ff:ff:ff:ff:ff
3: eth10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10000
link/ether 00:05:1b:a3:12:ce brd ff:ff:ff:ff:ff:ff
4: eth10.10@eth10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 5000
link/ether 00:05:1b:a3:12:ce brd ff:ff:ff:ff:ff:ff
5: eth10.20@eth10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 5000
link/ether 00:05:1b:a3:12:ce brd ff:ff:ff:ff:ff:ff
6: eth10.30@eth10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 5000
link/ether 00:05:1b:a3:12:ce brd ff:ff:ff:ff:ff:ff


/proc/net/vlan/config

VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
eth10.10 | 10 | eth10
eth10.20 | 20 | eth10
eth10.30 | 30 | eth10


/proc/net/vlan/eth10.10 - eth10.30

eth10.10 VID: 10 REORDER_HDR: 1 dev->priv_flags: 1
total frames received 73
total bytes received 24464
Broadcast/Multicast Rcvd 0

total frames transmitted 131
total bytes transmitted 58775
Device: eth10
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:1 7:2
EGRESS priority mappings: 0:3 2:1 4:3

eth10.20 VID: 20 REORDER_HDR: 1 dev->priv_flags: 1
total frames received 0
total bytes received 0
Broadcast/Multicast Rcvd 0

total frames transmitted 45
total bytes transmitted 7462
Device: eth10
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:1 7:2
EGRESS priority mappings: 0:3 2:1 4:3

eth10.30 VID: 30 REORDER_HDR: 1 dev->priv_flags: 1
total frames received 5
total bytes received 4152
Broadcast/Multicast Rcvd 0

total frames transmitted 50
total bytes transmitted 11656
Device: eth10
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:1 7:2
EGRESS priority mappings: 0:3 2:1 4:3

發表回應 發表回應 ( 226預覽 )   |  [ 0 引用 ]   |  permalink   |   ( 2.9 / 146 )


<前一頁 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 下一頁> 最後>>