ahoj doufám, že mi zde někdo chytrý poradí. mám aktuálně vps na kterém běží alpine linux na kterém hostuju kvm ubuntu 22.04. problém je v tom, že jsem docela nehezky řešil nastavení sítě, tak aby vps a kvm měli přístup z/do internetu jak z ipv4, tak i z ipv6. momentálně musím mít 2 interface(jeden je pro ipv4, druhý pro ipv6) nejradši kdyby to šlo nějak sloučit do jednoho interface se zachováním stejné konektivity vps i kvm.
Kdyby měl někdo myšlenku, či nápad, tak to vyzkouším na playground, až budu mít chvilku.
VPS je přístupný pouze na portech 1022(ssh),5900(vnc-defaultně zakázané v iptables- kdyby selhalo připojení KVM do sítě), zbytek udp/tcp portů je směrovaných do KVM
/etc/network/interfaces
# This file is generated by osctld from vpsAdminOS every time the container
# starts. Do not edit this file, your changes will be lost!
#
# Your custom configuration can be placed in /etc/network/interfaces.head
# and /etc/network/interfaces.tail, their contents will be embedded
# at the beginning and at the end of this file, respectively.
# If directory /etc/network/interfaces.d exists, all files from this directory
# are also sourced.
#
# To stop osctld from manipulating this file, run
#
# chmod u-w /etc/network/interfaces
#
# See interfaces(5), ifup(8) and ifdown(8).
# Autogenerated configuration
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 37.205.9.7
netmask 255.255.255.255
up ip -4 route add 255.255.255.254 dev eth0
up ip -4 route add default via 255.255.255.254 dev eth0
iface eth0 inet6 static
address 2a03:3b40:fe:234::1
netmask 64
up echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_dad
up ip -6 route add fe80::fc9e:13ff:feff:eac0 dev eth0
up ip -6 route add default via fe80::fc9e:13ff:feff:eac0 dev eth0
# Contents of /etc/network/interfaces.tail
auto br0
iface br0 inet static
pre-up brctl addbr br0
address 172.18.1.1
netmask 255.255.255.0
hwaddress FE:1F:77:02:57:58
post-down brctl delbr br0
up iptables -t nat -A POSTROUTING -s 172.18.1.0/24 ! -o br0 -j MASQUERADE
down up iptables -t nat -D POSTROUTING -s 172.18.1.0/24 ! -o br0 -j MASQUERADE
up iptables -A FORWARD -i br0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
up iptables -A FORWARD -i br0 -o eth0 -j ACCEPT
down iptables -D FORWARD -i br0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
down iptables -D FORWARD -i br0 -o eth0 -j ACCEPT
up iptables -t nat -A PREROUTING -d 37.205.9.7 -p tcp --dport 1:1021 -j DNAT --to 172.18.1.2
up iptables -I FORWARD -d 172.18.1.2/24 -p tcp -m state --state NEW -m tcp --dport 1:1021 -j ACCEPT
up iptables -t nat -A PREROUTING -d 37.205.9.7 -p udp --dport 1:1021 -j DNAT --to 172.18.1.2
up iptables -I FORWARD -d 172.18.1.2/24 -p udp -m state --state NEW -m udp --dport 1:1021 -j ACCEPT
up iptables -t nat -A PREROUTING -d 37.205.9.7 -p tcp --dport 1023:5899 -j DNAT --to 172.18.1.2
up iptables -I FORWARD -d 172.18.1.2/24 -p tcp -m state --state NEW -m tcp --dport 1023:5899 -j ACCEPT
up iptables -t nat -A PREROUTING -d 37.205.9.7 -p udp --dport 1023:5899 -j DNAT --to 172.18.1.2
up iptables -I FORWARD -d 172.18.1.2/24 -p udp -m state --state NEW -m udp --dport 1023:5899 -j ACCEPT
up iptables -t nat -A PREROUTING -d 37.205.9.7 -p tcp --dport 5901:65535 -j DNAT --to 172.18.1.2
up iptables -I FORWARD -d 172.18.1.2/24 -p tcp -m state --state NEW -m tcp --dport 5901:65535 -j ACCEPT
up iptables -t nat -A PREROUTING -d 37.205.9.7 -p udp --dport 5901:65535 -j DNAT --to 172.18.1.2
up iptables -I FORWARD -d 172.18.1.2/24 -p udp -m state --state NEW -m udp --dport 5901:65535 -j ACCEPT
up iptables -t nat -A PREROUTING -p icmp -d 37.205.9.7 -j DNAT --to-destination 172.18.1.2
up iptables -A FORWARD -p icmp -d 172.18.1.2 -j ACCEPT
down iptables -t nat -D PREROUTING -d 37.205.9.7 -p tcp --dport 1:1021 -j DNAT --to 172.18.1.2
down iptables -I FORWARD -d 172.18.1.2/24 -p tcp -m state --state NEW -m tcp --dport 1:1021 -j ACCEPT
down iptables -t nat -D PREROUTING -d 37.205.9.7 -p udp --dport 1:1021 -j DNAT --to 172.18.1.2
down iptables -I FORWARD -d 172.18.1.2/24 -p udp -m state --state NEW -m udp --dport 1:1021 -j ACCEPT
down iptables -t nat -D PREROUTING -d 37.205.9.7 -p tcp --dport 1023:5899 -j DNAT --to 172.18.1.2
down iptables -I FORWARD -d 172.18.1.2/24 -p tcp -m state --state NEW -m tcp --dport 1023:5899 -j ACCEPT
down iptables -t nat -D PREROUTING -d 37.205.9.7 -p udp --dport 1023:5899 -j DNAT --to 172.18.1.2
down iptables -I FORWARD -d 172.18.1.2/24 -p udp -m state --state NEW -m udp --dport 1023:5899 -j ACCEPT
down iptables -t nat -D PREROUTING -d 37.205.9.7 -p tcp --dport 5901:65535 -j DNAT --to 172.18.1.2
down iptables -I FORWARD -d 172.18.1.2/24 -p tcp -m state --state NEW -m tcp --dport 5901:65535 -j ACCEPT
down iptables -t nat -D PREROUTING -d 37.205.9.7 -p udp --dport 5901:65535 -j DNAT --to 172.18.1.2
down iptables -I FORWARD -d 172.18.1.2/24 -p udp -m state --state NEW -m udp --dport 5901:65535 -j ACCEPT
down iptables -t nat -D PREROUTING -p icmp -d 37.205.9.7 -j DNAT --to-destination 172.18.1.2
down iptables -D FORWARD -p icmp -d 172.18.1.2 -j ACCEPT
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
dns-nameservers 1.1.1.1 1.0.0.1
auto venet0
auto br1
iface br1 inet6 static
pre-up brctl addbr br1
post-up bash /etc/network/setup6.sh
address 2a03:3b40:3::29
hwaddress AA:48:06:45:D3:DC
netmask 64
pre-down brctl delif br1 eth0
post-down brctl delbr br1
/etc/network/setup6.sh
#!/bin/bash
IP4=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
IP4route=$(ip -4 route | grep default | cut -d ' ' -f 3)
IP61=$(ip a show eth0 | grep 'inet6 2' | awk '{print $2}' | cut -d "/" -f 1)
IP62=$(ip a show eth0 | grep 'inet6 f' | awk '{print $2}' | cut -d "/" -f 1)
IP6route=$(ip -6 route | grep default | cut -d ' ' -f 3)
echo $IP4
echo $IP4route
echo $IP61
echo $IP62
echo $IP6route
echo "flushing"
echo "1"
ip -6 a flush dev eth0
echo "2"
ip -6 a flush dev br1
echo "3"
ip a flush dev eth0
echo "4"
ip a flush dev br1
echo "5"
ip r flush dev eth0
echo "6"
ip r flush dev br1
echo "7"
ip -6 r flush dev eth0
echo "8"
ip -6 r flush dev br1
echo "add bridge"
brctl addif br1 eth0
echo " add ipv4"
ip a add $IP4 dev br1
echo "add ipv4 route"
ip r add $IP4route dev br1
ip r add default via $IP4route dev br1
echo "add ipv61"
ip -6 a add $IP61/64 dev br1
echo "echo add ipv62"
ip -6 a add $IP62/64 dev br1
echo "add ipv6 route"
ip -6 r add $IP6route dev br1
ip -6 r add default via $IP6route dev br1
síť v KVM
/etc/systemd/network/eth0.network
[Match]
MACAddress=aa:48:06:45:d3:dd
[Network]
Address=172.18.1.2/24
Gateway=172.18.1.1
DHCP=no
IPv6AcceptRA=false
LinkLocalAddressing=ipv6
DNS=1.1.1.1
[DHCP]
CriticalConnection=false
ClientIdentifier=mac
RouteMetric=100
UseMTU=false
/etc/systemd/network/eth1.network
[Match]
MACAddress=aa:48:06:45:d3:de
[Network]
Address= 2a03:3b40:25::1/48
netmask=48
Gateway=fe80::a848:6ff:fe45:d3dc
DHCP=no
IPv6AcceptRA=false
LinkLocalAddressing=ipv6
[DHCP]
CriticalConnection=false
ClientIdentifier=mac
RouteMetric=100
UseMTU=false