mirror of
https://passt.top/passt
synced 2025-05-30 12:55:42 +02:00
fwd, conf: Allow NAT of the guest's assigned address
The guest is usually assigned one of the host's IP addresses. That means it can't access the host itself via its usual address. The --map-host-loopback option (enabled by default with the gateway address) allows the guest to contact the host. However, connections forwarded this way appear on the host to have originated from the loopback interface, which isn't always desirable. Add a new --map-guest-addr option, which acts similarly but forwarded connections will go to the host's external address, instead of loopback. If '-a' is used, so the guest's address is not the same as the host's, this will instead forward to whatever host-visible site is shadowed by the guest's assigned address. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
8436c0d61b
commit
57b7bd2a48
4 changed files with 60 additions and 17 deletions
6
passt.h
6
passt.h
|
@ -104,6 +104,8 @@ enum passt_modes {
|
|||
* @guest_gw: IPv4 gateway as seen by the guest
|
||||
* @map_host_loopback: Outbound connections to this address are NATted to the
|
||||
* host's 127.0.0.1
|
||||
* @map_guest_addr: Outbound connections to this address are NATted to the
|
||||
* guest's assigned address
|
||||
* @dns: DNS addresses for DHCP, zero-terminated
|
||||
* @dns_match: Forward DNS query if sent to this address
|
||||
* @our_tap_addr: IPv4 address for passt's use on tap
|
||||
|
@ -120,6 +122,7 @@ struct ip4_ctx {
|
|||
int prefix_len;
|
||||
struct in_addr guest_gw;
|
||||
struct in_addr map_host_loopback;
|
||||
struct in_addr map_guest_addr;
|
||||
struct in_addr dns[MAXNS + 1];
|
||||
struct in_addr dns_match;
|
||||
struct in_addr our_tap_addr;
|
||||
|
@ -142,6 +145,8 @@ struct ip4_ctx {
|
|||
* @guest_gw: IPv6 gateway as seen by the guest
|
||||
* @map_host_loopback: Outbound connections to this address are NATted to the
|
||||
* host's [::1]
|
||||
* @map_guest_addr: Outbound connections to this address are NATted to the
|
||||
* guest's assigned address
|
||||
* @dns: DNS addresses for DHCPv6 and NDP, zero-terminated
|
||||
* @dns_match: Forward DNS query if sent to this address
|
||||
* @our_tap_ll: Link-local IPv6 address for passt's use on tap
|
||||
|
@ -158,6 +163,7 @@ struct ip6_ctx {
|
|||
struct in6_addr addr_ll_seen;
|
||||
struct in6_addr guest_gw;
|
||||
struct in6_addr map_host_loopback;
|
||||
struct in6_addr map_guest_addr;
|
||||
struct in6_addr dns[MAXNS + 1];
|
||||
struct in6_addr dns_match;
|
||||
struct in6_addr our_tap_ll;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue