summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vserver.functions13
1 files changed, 13 insertions, 0 deletions
diff --git a/vserver.functions b/vserver.functions
index a75d717..8c25f74 100644
--- a/vserver.functions
+++ b/vserver.functions
@@ -47,6 +47,14 @@ function _netnsProcessSingleGateway() {
_addInterfaceCmd IP_ROUTE default via "$gw" dev "$iface"
}
+function _netnsAddLocalhost() {
+ if [ -r "${1}/nflags" ]; then
+ if grep -q '^~LBACK_REMAP$' "${1}/nflags"; then
+ INTERFACES=( "${INTERFACES[@]}" "127.0.0.1/8" "::1/128" )
+ fi
+ fi
+}
+
function _netnsFilterNetnsUmount() {
local args=( "$@" )
@@ -93,13 +101,18 @@ function _generateInterfaceOptions() {
ret=$?
# add commands for default route
+ local netns=0
for net in "$VSERVER_DIR/netns/"*; do
test -d "$net" || continue
test ! -e "${net}/disabled" || continue
_netnsProcessSingleGateway "$net"
+ netns=1
done
+ # if using netns, automatically add localhost
+ [ "$netns" != "0" ] && _netnsAddLocalhost "$VSERVER_DIR"
+
return $ret
}