나는 네트워킹 멍청한 놈이고 도움이 필요할 수 있습니다.
원격 서버의 VLAN에 있는 장치에 액세스하기 위해 OpenVPN을 사용하여 TAP 연결을 설정하려고 합니다. 지금은 인터페이스(172.20.0.101)에 연결하고 핑할 수 있지만 VLAN(예: 172.20.0.2)에서는 아무 것도 핑할 수 없습니다. VPN 연결을 통해 VLAN이 들어오는 것에 대해서는 신경 쓰지 않고 해당 장치를 볼 수 있기를 원합니다.
서버의 "공용" IP는 10.249.2.93입니다(실제로는 다른 VPN을 통해 연결하는 LAN입니다).
ifconifg에 따르면 내가 통신할 수 있는 서브넷은 vlan.3072에 있는 172.20.0.0/24입니다. 연관된 물리적 인터페이스는 enp3s0입니다.
VLAN을 사용하지 않는 다른 서버에서 이 작업을 수행했습니다. 즉, 해당 서버 뒤의 일반 LAN에 있는 장치에 성공적으로 연결할 수 있었기 때문에 VLAN이 문제라고 생각합니다.
누구든지 올바른 방향으로 나를 가리킬 수 있습니까? 정신을 잃을 것 같으니 어떤 도움이라도 대단히 감사하겠습니다 =P
서버가 Ubuntu 18.04 LTS, OpenVPN 2.4.4를 실행 중입니다.
클라이언트가 Windows, OpenVPN GUI 11.14.0.0을 실행 중입니다.
서버.conf:
port 1194
proto udp
dev tap0
ca ca.crt
cert server.crt
key server.key # This file should be kept secret
ifconfig-pool-persist /var/log/openvpn/ipp.txt
server-bridge 172.20.0.101 255.255.255.0 172.20.0.200 172.20.0.240
keepalive 10 120
tls-auth ta.key 0 # This file is secret
key-direction 0
cipher AES-256-CBC
auth SHA256
persist-key
persist-tun
status /var/log/openvpn/openvpn-status.log
verb 4
explicit-exit-notify 1
tls-auth ta.key 0
key-direction 0
cipher AES-256-CBC
auth SHA256
dh dh.pem
user nobody
group nogroup
cert server.crt
key server.key
clinet.ovpn:
client
dev tap
proto udp
remote 10.249.2.93 1194
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
remote-cert-tls server
cipher AES-256-CBC
auth SHA256
key-direction 1
script-security 2
verb 4
# cert and keys omitted
ufw 규칙:
sudo nano /etc/ufw/before.rules
#change:
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 172.20.0.0/24 -o br0 -j MASQUERADE
COMMIT
전송:
sudo nano /etc/sysctl.conf
#change:
net.ipv4.ip_forward=1
sudo sysctl -p
규칙 업데이트:
sudo ufw allow 1194/udp
sudo ufw allow OpenSSH
sudo ufw disable
sudo ufw enable
sudo iptables -A INPUT -i tap0 -j ACCEPT
sudo iptables -A INPUT -i br0 -j ACCEPT
sudo iptables -A FORWARD -i br0 -j ACCEPT
브리지 시작 스크립트:
# Define Bridge Interface
br="br0"
# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
tap="tap0"
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="enp3s0"
eth_ip="fe80::a5a:11ff:fe33:e6e3"
eth_netmask="255.255.255.0"
eth_broadcast="172.20.0.255"
for t in $tap; do
openvpn --mktun --dev $t
done
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t
done
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up
done
ifconfig $eth 0.0.0.0 promisc up
ifconfig $br inet6 add fe80::a5a:11ff:fe33:e6e3/64 up
ifconfig br0:0 172.20.0.101 netmask 255.255.255.0 broadcast 172.20.0.255 up
ifconfig(br0 또는 tap0을 지금 당장 시작할 수 없고 생략한 다른 veth*가 너무 많기 때문에 표시하지 않음):
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:60ff:fe8c:45de prefixlen 64 scopeid 0x20<link>
ether 02:42:60:8c:45:de txqueuelen 0 (Ethernet)
RX packets 74394 bytes 900967774 (900.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 63778 bytes 901066960 (901.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.249.2.93 netmask 255.255.240.0 broadcast 10.249.15.255
inet6 fe80::c600:adff:fe94:e303 prefixlen 64 scopeid 0x20<link>
ether c4:00:ad:94:e3:03 txqueuelen 1000 (Ethernet)
RX packets 960832 bytes 1168467699 (1.1 GB)
RX errors 0 dropped 166 overruns 0 frame 0
TX packets 535763 bytes 73093159 (73.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xb2500000-b2520000
enp1s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 08:5a:11:33:e8:00 txqueuelen 1000 (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
enp3s0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
inet6 fe80::a5a:11ff:fe33:e6e3 prefixlen 64 scopeid 0x20<link>
ether 08:5a:11:33:e6:e3 txqueuelen 1000 (Ethernet)
RX packets 9900475 bytes 7053325760 (7.0 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10464489 bytes 8238594873 (8.2 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
kube-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1480
inet 10.244.0.1 netmask 255.255.255.0 broadcast 10.244.0.255
inet6 fe80::841:c2ff:fed1:3642 prefixlen 64 scopeid 0x20<link>
ether 0a:41:c2:d1:36:42 txqueuelen 1000 (Ethernet)
RX packets 2110720 bytes 234803960 (234.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2264621 bytes 419964189 (419.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 8383864 bytes 4038115926 (4.0 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8383864 bytes 4038115926 (4.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
veth83317517: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1480
inet6 fe80::d4c3:65ff:fe76:7592 prefixlen 64 scopeid 0x20<link>
ether d6:c3:65:76:75:92 txqueuelen 0 (Ethernet)
RX packets 28251 bytes 7794531 (7.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 29314 bytes 3608931 (3.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vlan.2560: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.19.0.1 netmask 255.255.128.0 broadcast 172.19.127.255
inet6 fe80::a5a:11ff:fe33:e6e3 prefixlen 64 scopeid 0x20<link>
ether 08:5a:11:33:e6:e3 txqueuelen 1000 (Ethernet)
RX packets 70170 bytes 25019840 (25.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 179 bytes 17252 (17.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vlan.2816: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.19.130.100 netmask 255.255.255.0 broadcast 172.19.130.255
inet6 fe80::a5a:11ff:fe33:e6e3 prefixlen 64 scopeid 0x20<link>
ether 08:5a:11:33:e6:e3 txqueuelen 1000 (Ethernet)
RX packets 1243206 bytes 65936318 (65.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1194999 bytes 99652577 (99.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vlan.3072: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
inet 172.20.0.100 netmask 255.255.255.0 broadcast 172.20.0.255
inet6 fe80::a5a:11ff:fe33:e6e3 prefixlen 64 scopeid 0x20<link>
ether 08:5a:11:33:e6:e3 txqueuelen 1000 (Ethernet)
RX packets 8544935 bytes 6820405811 (6.8 GB)
RX errors 0 dropped 511 overruns 0 frame 0
TX packets 9265376 bytes 8138226312 (8.1 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
IP a를 제외하고:
7: vlan.3072@enp3s0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 08:5a:11:33:e6:e3 brd ff:ff:ff:ff:ff:ff
inet 172.20.0.100/24 brd 172.20.0.255 scope global vlan.3072
valid_lft forever preferred_lft forever
inet6 fe80::a5a:11ff:fe33:e6e3/64 scope link
valid_lft forever preferred_lft forever
답변1
의 브리지 구성은 과 bridge-start
사이에 브리지를 만들 므로 클라이언트에서 오는 모든 프레임은 VLAN 태그 없이 종료됩니다 . 이것이 바로 VLAN 없이도 작동하는 이유이고 VLAN에서는 작동하지 않는 이유입니다. 설정이 작동하려면 서버 측 과 서버 측을 연결해야 하므로 스크립트 에서 으로 변경하면 됩니다 .tap
enp3s0
enp3s0
tap
vlan.3072
enp3s0
vlan.3072
bridge-start