Ubuntu 17.10 - OpenVPN TAP - 帮助

Ubuntu 17.10 - OpenVPN TAP - 帮助

我现在很绝望。我一直在尝试在 Ubuntu 17.10 上配置桥接网络,但结果很糟糕。我在网上找不到任何文档来帮助安装。我找到的所有文档都是针对 16.04 及以下版本编写的。有人能帮帮我吗?有了这个网络计划实现而不是接口,一切似乎都很令人头疼。以下是我的配置。

信息:

router: 10.0.1.1
ip address 10.0.1.100
network 10.0.1.0
gateway 10.0.1.1
dns: 10.0.1.1
netmask 255.255.255.0

admin@SKYNET:~$ cat /etc/netplan/01-netcfg.yaml
This file describes the network interfaces available on your system
For more information, see netplan(5).

network:
version: 2
renderer: networkd
ethernets:
enp0s31f6:
dhcp4: yes
bridges:
br0:
interfaces: [enp0s31f6]
dhcp4: true
optional: true

admin@SKYNET:~$ cat /etc/openvpn/server.conf
port 1194
proto udp
dev tap
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
ifconfig-pool-persist ipp.txt
server-bridge 10.0.1.100 255.255.255.0 10.0.1.230 10.0.1.254
push "route 10.0.1.0 255.255.255.0 10.0.1.1"
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 10.0.1.1"
client-to-client
keepalive 10 120
tls-auth ta.key 0
cipher AES-256-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
explicit-exit-notify 1

admin@SKYNET:~$ cat /etc/openvpn/easy-rsa/keys/client.ovpn
client
dev tap
proto udp
remote 1194
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
remote-cert-tls server
tls-auth ta.key 1
cipher AES-256-CBC
comp-lzo
verb 3

我按照以下步骤进行操作Ubuntu 帮助 wiki 上的此页面准备服务器上桥接的接口配置步骤似乎不起作用,因为接口不再有。不知道如何调高tap0/调低。客户端连接时似乎遇到了路由问题。

[admin@SKYNET:~$ ifconfig br0
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.1.100 netmask 255.255.255.0 broadcast 10.0.1.255
inet6 fe80::c96:daff:feda:65b8 prefixlen 64 scopeid 0x20
ether 0e:96:da:da:65:b8 txqueuelen 1000 (Ethernet)
RX packets 1327461 bytes 2776343355 (2.7 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 953269 bytes 1907343180 (1.9 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[admin@SKYNET:~$ ifconfig tap0
tap0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 0a:82:dd:10:85:4d txqueuelen 100 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

我还添加了防火墙规则

iptables -A INPUT -i tap0 -j ACCEPT
iptables -A INPUT -i br0 -j ACCEPT
iptables -A FORWARD -i br0 -j ACCEPT

我究竟做错了什么?

答案1

您不想在网桥和物理接口上都配置地址,而这正是在两个地方都设置了 dhcp4: true 时会发生的情况。要匹配中描述的配置https://help.ubuntu.com/lts/serverguide/openvpn.html.en#openvpn-advanced-config,你的 netplan yaml 应该如下所示:

$ cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5).

network: version: 2 renderer: networkd ethernets: enp0s31f6: dhcp4: no bridges: br0: interfaces: [enp0s31f6] dhcp4: no addresses: [10.0.1.100/24] gateway4: 10.0.1.1 nameservers: addresses: [10.0.1.1] 请注意,这使用静态地址配置。DHCP 也可以工作,但系统上的其他配置文件(openvpn.conf)具有静态配置的 IP 信息是没有意义的,但主机网络使用 DHCP 是没有意义的。

您不需要将此接口声明为“可选”,这仅与其他 systemd 单元将在启动时等待此接口配置有关。

ifupdown 配置中不能转换为 netplan 的另一部分是“promisc”命令:up ip link set $IFACE up promisc on。要在使用 netplan 的系统上执行等效操作,请确保已networkd-dispatcher安装该软件包,然后以以下脚本的身份安装/usr/lib/networkd-dispatcher/dormant.d/promisc_bridge(由 root 拥有,标记为可执行文件):

#!/bin/sh set -e if [ "$IFACE" = br0 ]; then # no networkd-dispatcher event for 'carrier' on the physical interface ip link set eth0 up promisc on fi

相关内容