---
# System prepended metadata

title: Virtual Router架設

---

# Virtual Router架設

* Ubuntu 20.04 server
* 更改網卡名稱
```bash=
$sudo vim /etc/udev/rules.d/75-persistent-net-generator.rules

# 格式: SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="網路卡MAC位址", NAME="網路卡新名稱"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:51:3c:5b", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:f4:06:a1", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:7d:4c:81", NAME="eth2"
```
* 網卡設定
```bash=
$sudo vim /etc/netplan/00-installer-config.yaml

network:
  renderer: NetworkManager
  ethernets:
    ensXX:
      addresses:
      - XX.XX.XX.XX
      gateway4: XX.XX.XX.XX
      nameservers:
        search:
        - XX.XX.XX.XX
        addresses:
        - XX.XX.XX.XX
```
* 封包傳送設定
```bash=
$sudo vim /etc/sysctl.conf

...
net.ipv4.ip_forward=1
net.ipv4.conf.all.proxy_arp=1
net.ipv4.conf.all.accept_source_route=1
...
```
* iptables儲存
```bash=
$iptables-save > /etc/iptables/rule.v4
```
* 結束
    * judge - 