[Share Experiences] Linux下手动创建nat网络
Tofloor
poster avatar
风吹过的绿洲
deepin
2022-11-08 06:09
Author

image.png

这个虚拟网卡的配置

内容请看5楼

Reply Favorite View the author
All Replies
liwl
deepin
2022-11-08 06:36
#1

你要编辑什么?

用sudo virsh net-edit default 进行编辑

直接修改配置文件也可以,但是应该需要导入配置,重启服务

配置明天贴,手机回复,忘记路径了

Reply View the author
风吹过的绿洲
deepin
2022-11-08 06:41
#2
liwl

你要编辑什么?

用sudo virsh net-edit default 进行编辑

直接修改配置文件也可以,但是应该需要导入配置,重启服务

配置明天贴,手机回复,忘记路径了

我的PVE,相加一个特定网段的虚拟网卡,不知道怎么加,想仿照这个加一个。

Reply View the author
liwl
deepin
2022-11-08 06:44
#3
风吹过的绿洲

我的PVE,相加一个特定网段的虚拟网卡,不知道怎么加,想仿照这个加一个。

这个网卡是kvm的nat模式虚拟网卡。你可以安装virt-manager进行可视化管理,包括虚拟网卡的增删

Reply View the author
风吹过的绿洲
deepin
2022-11-08 07:56
#4
liwl

这个网卡是kvm的nat模式虚拟网卡。你可以安装virt-manager进行可视化管理,包括虚拟网卡的增删

pve是一个虚拟机平台,本身也是基于kvm的,就不再弄kvm了

Reply View the author
风吹过的绿洲
deepin
2022-11-08 09:04
#5

按照这个连接解决了

双局域网共享

https://blog.csdn.net/kangseung/article/details/115857671

root@pve:/etc/network# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 vmbr0
10.10.10.0      0.0.0.0         255.255.255.0   U     0      0        0 vmbr1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 vmbr0
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 enp9s0
 
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!
 
auto lo
iface lo inet loopback
 
iface enp8s0 inet manual
 
iface enp9s0 inet manual
 
 
auto vmbr0
iface vmbr0 inet static
	address 192.168.1.117/24
	netmask 255.255.255.0
	gateway 192.168.1.1
	bridge-ports enp8s0
	bridge-stp off
	bridge-fd 0
 
# 可以共享vmbr0的网络
auto vmbr1
iface vmbr1 inet static
	address 10.10.10.1/24
	bridge-ports none
	bridge-stp off
	bridge-fd 0
	post-up echo 1 > /proc/sys/net/ipv4/ip_forward
	post-up echo 1 > /proc/sys/net/ipv4/conf/vmbr1/proxy_arp
	post-up iptables -t nat -F
	post-up iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -o vmbr0 -j MASQUERADE
	post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 10.10.10.200:8080
    	post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 50022 -j DNAT --to 10.10.10.200:22
        post-up   iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
        post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1
 
# 不可连接连外网
auto vmbr3
iface vmbr3 inet static
	address 192.168.10.117/24
	netmask 255.255.255.0
	bridge-ports enp9s0
	bridge-stp off
	bridge-fd 0
Reply View the author