# Setup OpenWRT trên Proxmox: Tạo Switch Ports để xài cho các lỗ cắm Ethernet còn dư

Cách setup trên Proxmox:

Blog post: [https://community.bigbeartechworld.com/t/setting-up-openwrt-on-a-virtual-machine-with-proxmox/257](https://community.bigbeartechworld.com/t/setting-up-openwrt-on-a-virtual-machine-with-proxmox/257)

Image File: generic-ext4-rootfs.img.gz

[https://downloads.openwrt.org/releases/23.05.2/targets/x86/64/](https://downloads.openwrt.org/releases/23.05.2/targets/x86/64/)

Cài đặt theo cấu hình như tutorial này: [https://gist.github.com/dragonfire1119/f3acd42414abfff762d2dad5e50f7cc6](https://gist.github.com/dragonfire1119/f3acd42414abfff762d2dad5e50f7cc6)

Tắt máy và add thêm các cổng trên VM Proxmox, như hình dưới mình có 2 cổng, 1 cổng kết nối mạng và một cổng làm switch tới máy khác.

Bước một tạo thêm Bridge Port trên Node, vào rack2 -&gt; System -&gt; Network -&gt; chọn Create -&gt; Linux Bridge

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/i1ximage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/i1ximage.png)

Bạn có thể thấy 2 network device, eno1, eno2 tương ứng cho vmbr0, vmbr1:

Nếu không có hiện các device eno1, eno2 thì có thể là tên khác tùy theo hardware / cpu manufacturer.

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/mYUimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/mYUimage.png)

Còn không có các device gì hết thì bạn thử cắm ethernet vào switch trước cho nó nhận ( nhớ restart lại )

Kết tiếp vào VM Openwrt của bạn , phần hardware, thêm vào vmbr1 vmbr2 vmbr3 (nếu có 4 ports ethernet)

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/fkUimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/fkUimage.png)

Đăng nhập vào web browser ui của openwrt trên trình duyệt:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/FWbimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/FWbimage.png)

vào phần network interfaces

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/YJtimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/YJtimage.png)

Tạo / Sửa interface:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/0OJimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/0OJimage.png)

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/bODimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/bODimage.png)

Cập nhập dns ip:

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/ERsimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/ERsimage.png)

2 DNS IP là mình tạo 2 instance Pihole, một cái làm Primary local dns, 1 cái làm secondary để phụ trợ cho cái primary dns.

Primary DNS đi trước, secondary DNS ip đi sau.

Save

Vào Device Tab và chọn configure... cho Bridge Lan

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/eRWimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/eRWimage.png)

Thêm / Check vào ports cần làm switch ports

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/m7timage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/m7timage.png)

Save

[![image.png](https://wiki.kyluat.com/uploads/images/gallery/2024-06/scaled-1680-/QkCimage.png)](https://wiki.kyluat.com/uploads/images/gallery/2024-06/QkCimage.png)

Save &amp; Apply

Ssh vào máy và đánh các command sau để cài đặt các package cần thiết cho vm:

```
opkg update
opkg install qemu-ga
```

Restart lại VM