|
@@ -0,0 +1,24 @@
|
|
|
+# 双网卡内外网
|
|
|
+在 /etc/network/interfaces 中的正确配置
|
|
|
+确保在配置文件中正确指定设备:
|
|
|
+```
|
|
|
+# 主网卡 - 设置默认路由
|
|
|
+auto enp3s0
|
|
|
+iface enp3s0 inet static
|
|
|
+ address 192.168.193.100
|
|
|
+ netmask 255.255.255.0
|
|
|
+ gateway 192.168.193.1
|
|
|
+ dns-nameservers 114.114.114.114
|
|
|
+ metric 100
|
|
|
+
|
|
|
+# 第二张网卡 - 不设置默认路由
|
|
|
+auto enp4s0
|
|
|
+iface enp4s0 inet static
|
|
|
+ address 10.168.2.66
|
|
|
+ netmask 255.255.255.0
|
|
|
+ gateway 10.168.2.1
|
|
|
+ metric 101
|
|
|
+ # 添加特定路由时也要指定 dev 参数
|
|
|
+ up ip route add 10.168.2.0/24 via 10.168.2.1 dev enp4s0 metric 102
|
|
|
+ up ip route add 10.168.1.0/24 via 10.168.2.1 dev enp4s0 metric 103
|
|
|
+```
|