1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Realtek の USB NIC に VLAN を割り当てる

Last updated at Posted at 2021-02-05

USB NIC で VLAN 接続する

Windwos10 に

使用した NIC

Belkin USB-C to Gigabit Ethernet + USB-C 60W PD対応 有線LAN 変換アダプター INC001btBK-A

Vlan の設定に Diagnostic Program for Win7/Win8/Win10 をダウンロードしてインストールする。
ついでに、Driver も同じページからダウンロードできるのでアップデートしてみる。

ネットワークアドレス

Vlan NetWork Cisco2901 (Gi0/0) PC (USB NIC)
10 10.0.10.0/24 10.0.10.1 10.0.10.10
20 10.0.20.0/24 10.0.20.1 10.0.20.10
30 10.0.30.0/24 10.0.30.1 10.0.30.10
40 10.0.40.0/24 10.0.40.1 10.0.40.10
50 10.0.50.0/24 10.0.50.1 10.0.50.10

VLAN を作る

デフォルトで有効だが、念のため VLAN が有効になっていることを確認する。
イーサネットのプロパティから「構成」を選択
image.png
開いたウィンドウで「詳細設定」タブを選択し、VLAN が有効になっていることを確認。
image.png

確認が終わったので、先ほどインストールした Diagnostic Utility をスタートメニューから起動。
image.png
対象の NIC の VLAN 欄を選択し VLAN を追加する。
image.png
順番に追加したのに、順番に並びませんねぇ。

インターフェイスの名前を変更

image.png
分かりにくいので、インターフェイスの名前を VLAN番号に変更する。

image.png

image.png

IP アドレスを設定

一つ一つ開いて設定するのは面倒なので PowerShell で設定する。

IP設定.ps1
$ifs = @(
	# New-NetIPAddress の引数を指定
	# @{InterfaceAlias = "" ; IPAddress = "" ; PrefixLength = "" ; -DefaultGateway ""}
	@{InterfaceAlias = "VLAN0010" ; IPAddress = "10.0.10.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0020" ; IPAddress = "10.0.20.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0030" ; IPAddress = "10.0.30.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0040" ; IPAddress = "10.0.40.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0050" ; IPAddress = "10.0.50.10" ; PrefixLength = "24"}
)

foreach ($if in $ifs){
	# 設定前に削除が必要
	Get-NetIPAddress -InterfaceAlias $if.InterfaceAlias | Remove-NetIPAddress -Confirm:$false > $null
	# デフォルトルートが設定されていれば削除
	Remove-NetRoute -InterfaceAlias $if.InterfaceAlias -DestinationPrefix 0.0.0.0/0 -Confirm:$false 2> $null

	# アドレスを設定
	New-NetIPAddress -AddressFamily IPv4 @if > $null

	Get-NetIPAddress -InterfaceAlias $if.InterfaceAlias | Select-Object InterfaceAlias,IPAddress,PrefixLength
}

# Get-NetIPConfiguration |? InterfaceAlias -Match 'VLAN*' | Select-Object * | Out-GridView
実行結果
InterfaceAlias IPAddress  PrefixLength
-------------- ---------  ------------
VLAN0010       10.0.10.10           24
VLAN0020       10.0.20.10           24
VLAN0030       10.0.30.10           24
VLAN0040       10.0.40.10           24
VLAN0050       10.0.50.10           24

Cisco 側のインターフェース設定

conf t
interface GigabitEthernet0/0
 no ip address
 no shutdown
 duplex full
 speed 1000

interface GigabitEthernet0/0.10
 encapsulation dot1q 10
 ip address 10.0.10.1 255.255.255.0

interface GigabitEthernet0/0.20
 encapsulation dot1q 20
 ip address 10.0.20.1 255.255.255.0

interface GigabitEthernet0/0.30
 encapsulation dot1q 30
 ip address 10.0.30.1 255.255.255.0

interface GigabitEthernet0/0.40
 encapsulation dot1q 40
 ip address 10.0.40.1 255.255.255.0

interface GigabitEthernet0/0.50
 encapsulation dot1q 50
 ip address 10.0.50.1 255.255.255.0

接続確認

ping
Router#ping 10.0.10.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.10.10, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/4 ms
Router#ping 10.0.20.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.20.10, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/4 ms
Router#ping 10.0.30.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.30.10, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/4 ms
Router#ping 10.0.40.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.40.10, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/4 ms
Router#ping 10.0.50.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.50.10, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/4 ms
Router#

普通に繋がりますねぇ。

native vlan

vlan 7 を native vlan (タグなし) にする。
先ほどから vlan 7, 29 を追加。

Vlan NetWork Cisco2901 (Gi0/0) PC (USB NIC)
7 10.0.7.0/24 10.0.7.1 10.0.7.10
10 10.0.10.0/24 10.0.10.1 10.0.10.10
20 10.0.20.0/24 10.0.20.1 10.0.20.10
29 10.0.29.0/24 10.0.29.1 10.0.29.10
30 10.0.30.0/24 10.0.30.1 10.0.30.10
40 10.0.40.0/24 10.0.40.1 10.0.40.10
50 10.0.50.0/24 10.0.50.1 10.0.50.10

Windows 側

vlan0029 を作成しアドレスを設定。(vlan7 は通常のインターフェイスに設定)

IP設定.ps1
$ifs = @(
	# New-NetIPAddress の引数を指定
	# @{InterfaceAlias = "" ; IPAddress = "" ; PrefixLength = "" ; -DefaultGateway ""}
	@{InterfaceAlias = "イーサネット" ; IPAddress = "10.0.7.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0010" ; IPAddress = "10.0.10.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0020" ; IPAddress = "10.0.20.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0029" ; IPAddress = "10.0.29.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0030" ; IPAddress = "10.0.30.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0040" ; IPAddress = "10.0.40.10" ; PrefixLength = "24"}
	@{InterfaceAlias = "VLAN0050" ; IPAddress = "10.0.50.10" ; PrefixLength = "24"}
)

foreach ($if in $ifs){
    # 設定前に削除が必要
	Get-NetIPAddress -InterfaceAlias $if.InterfaceAlias | Remove-NetIPAddress -Confirm:$false > $null
    # デフォルトルートが設定されていれば削除
	Remove-NetRoute -InterfaceAlias $if.InterfaceAlias -DestinationPrefix 0.0.0.0/0 -Confirm:$false 2> $null

    # アドレスを設定
	New-NetIPAddress -AddressFamily IPv4 @if > $null

    Get-NetIPAddress -InterfaceAlias $if.InterfaceAlias | Select-Object InterfaceAlias,IPAddress,PrefixLength
}

# Get-NetIPConfiguration |? InterfaceAlias -Match 'VLAN*' | Select-Object * | Out-GridView

Cisco 側

conf t
interface GigabitEthernet0/0
 no ip address
 no shutdown
 duplex full
 speed 1000

interface GigabitEthernet0/0.7
 encapsulation dot1q 7 native
 ip address 10.0.7.1 255.255.255.0

interface GigabitEthernet0/0.10
 encapsulation dot1q 10
 ip address 10.0.10.1 255.255.255.0

interface GigabitEthernet0/0.20
 encapsulation dot1q 20
 ip address 10.0.20.1 255.255.255.0

interface GigabitEthernet0/0.29
 encapsulation dot1q 29
 ip address 10.0.29.1 255.255.255.0

interface GigabitEthernet0/0.30
 encapsulation dot1q 30
 ip address 10.0.30.1 255.255.255.0

interface GigabitEthernet0/0.40
 encapsulation dot1q 40
 ip address 10.0.40.1 255.255.255.0

interface GigabitEthernet0/0.50
 encapsulation dot1q 50
 ip address 10.0.50.1 255.255.255.0

うん、繋がりますね。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?