mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
fix: Port forwarding (#517)
This commit is contained in:
parent
f28b9903f3
commit
e6193b1020
@ -104,6 +104,14 @@ configureNAT() {
|
|||||||
error "TUN device missing. $ADD_ERR --cap-add NET_ADMIN" && exit 25
|
error "TUN device missing. $ADD_ERR --cap-add NET_ADMIN" && exit 25
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check port forwarding flag
|
||||||
|
if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
||||||
|
{ sysctl -w net.ipv4.ip_forward=1 ; rc=$?; } || :
|
||||||
|
if (( rc != 0 )); then
|
||||||
|
error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1" && exit 24
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Create a bridge with a static IP for the VM guest
|
# Create a bridge with a static IP for the VM guest
|
||||||
|
|
||||||
VM_NET_IP='20.20.20.21'
|
VM_NET_IP='20.20.20.21'
|
||||||
@ -148,14 +156,6 @@ configureNAT() {
|
|||||||
{ set +x; } 2>/dev/null
|
{ set +x; } 2>/dev/null
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo
|
[[ "$DEBUG" == [Yy1]* ]] && echo
|
||||||
|
|
||||||
# Check port forwarding flag
|
|
||||||
if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
|
|
||||||
{ sysctl -w net.ipv4.ip_forward=1 ; rc=$?; } || :
|
|
||||||
if (( rc != 0 )); then
|
|
||||||
error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1" && exit 24
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
NET_OPTS="-netdev tap,ifname=$VM_NET_TAP,script=no,downscript=no,id=hostnet0"
|
NET_OPTS="-netdev tap,ifname=$VM_NET_TAP,script=no,downscript=no,id=hostnet0"
|
||||||
|
|
||||||
{ exec 40>>/dev/vhost-net; rc=$?; } 2>/dev/null || :
|
{ exec 40>>/dev/vhost-net; rc=$?; } 2>/dev/null || :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user