Hadyai Internet R&D LAB

แหล่งความรู้ => Server => Linux Server System => ข้อความที่เริ่มโดย: admin ที่ 23 กรกฎาคม 2015, 05:12:35

หัวข้อ: swconfig บน BPI-R1
เริ่มหัวข้อโดย: admin ที่ 23 กรกฎาคม 2015, 05:12:35
(http://www.hadyaiinternet.com/images/ports.jpg)

ตัวอย่างไฟล์  /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
    pre-up swconfig dev eth0 set reset 1
    pre-up swconfig dev eth0 set enable_vlan 1
    pre-up swconfig dev eth0 vlan 201 set ports '3 8t'  #LAN0
    pre-up swconfig dev eth0 vlan 101 set ports '2 8t'  #WAN1
    pre-up swconfig dev eth0 vlan 102 set ports '1 8t'  #WAN2
    pre-up swconfig dev eth0 vlan 103 set ports '0 8t'  #WAN3
    pre-up swconfig dev eth0 vlan 104 set ports '4 8t'  #WAN4
    pre-up swconfig dev eth0 set apply 1

#LAN0
auto eth0.201
iface eth0.201 inet static
    pre-up ifconfig eth0.201 hw ether 02:96:07:c1:62:01
    address 192.168.200.1
    netmask 255.255.255.0

#WAN1
auto eth0.101
iface eth0.101 inet manual
    pre-up ifconfig eth0.101 hw ether 02:96:07:c1:61:01

#WAN2
auto eth0.102
iface eth0.102 inet manual
    pre-up ifconfig eth0.102 hw ether 02:96:07:c1:61:02

#WAN3
auto eth0.103
iface eth0.103 inet manual
    pre-up ifconfig eth0.103 hw ether 02:96:07:c1:61:03

#WAN4
auto eth0.104
iface eth0.104 inet manual
    pre-up ifconfig eth0.104 hw ether 02:96:07:c1:61:04

#WIFI
allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
    address 10.0.0.1
    netmask 255.255.255.0

วิธีตรวจสอบการเชื่อมต่อแต่ละ port

# ./ethlink.sh
WAN1 link:up speed:1000baseT full-duplex auto
WAN2 link:down
WAN3 link:down
WAN4 link:down
LAN0 link:up speed:1000baseT full-duplex auto
#

โค๊ด: [Select]
#!/bin/bash

WAN1=$(swconfig dev eth0 port 2 get link | cut -c8-)
WAN2=$(swconfig dev eth0 port 1 get link | cut -c8-)
WAN3=$(swconfig dev eth0 port 0 get link | cut -c8-)
WAN4=$(swconfig dev eth0 port 4 get link | cut -c8-)
LAN0=$(swconfig dev eth0 port 3 get link | cut -c8-)

echo WAN1 $WAN1
echo WAN2 $WAN2
echo WAN3 $WAN3
echo WAN4 $WAN4
echo LAN0 $LAN0