mirror of
https://git.FreeBSD.org/ports.git
synced 2024-10-20 20:09:11 +00:00
Switch the port over to netgraph bridging. This method has a number of
advantages, chief of which is that it doesn't hose over multi-interface configurations the way the default installation did before. This mechanism "chains" the guest's interface to an interface specified at installation-time (it can be changed afterwards by editing the rc.d script). Approved by: (maintainer)
This commit is contained in:
parent
b1a016d41b
commit
7a7a493036
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=36295
@ -102,6 +102,8 @@ setoptions:
|
||||
${SED} -e 's;@@PREFIX@@;${PREFIX};' \
|
||||
-e 's;@@LINUXBASE@@;${LINUXBASE};' \
|
||||
-e 's;@@NETWORKING@@;${VMNET_NETWORKING};' \
|
||||
-e 's;@@BRIDGED@@;${VMNET_BRIDGED};' \
|
||||
-e 's;@@BRIDGE_INTF@@;${VMNET_BRIDGED_INTERFACE};' \
|
||||
${FILESDIR}/vmware.sh > ${WRKDIR}/vmware.sh
|
||||
|
||||
${SED} -e 's;@@PREFIX@@;${PREFIX};' \
|
||||
|
@ -24,6 +24,8 @@ vmware_config() {
|
||||
vmware=`vmware_config vmware.fullpath`
|
||||
vmware_libdir=`vmware_config libdir`
|
||||
networking=@@NETWORKING@@
|
||||
bridged=@@BRIDGED@@
|
||||
bridge_interface=@@BRIDGE_INTF@@
|
||||
host_ip=`vmware_config vmnet1.HostOnlyAddress`
|
||||
netmask=`vmware_config vmnet1.HostOnlyNetMask`
|
||||
dev_vmnet1=@@LINUXBASE@@/dev/vmnet1
|
||||
@ -45,7 +47,6 @@ case $1 in
|
||||
start)
|
||||
kldload ${vmware_libdir}/modules/vmmon_${suffix}.ko
|
||||
if [ $networking -eq 1 ]; then
|
||||
sysctl net.link.ether.bridge_refresh && bridge="_bridge"
|
||||
kldload if_tap.ko
|
||||
if [ ! -e $dev_vmnet1 ]; then
|
||||
echo "$dev_vmnet1 does not exist!" >&2
|
||||
@ -54,12 +55,21 @@ start)
|
||||
fi
|
||||
echo -n > $dev_vmnet1
|
||||
ifconfig vmnet1 $host_ip netmask $netmask
|
||||
if [ _$bridge != _ ]; then
|
||||
sysctl -w net.link.ether.bridge_refresh=1
|
||||
sysctl -w net.link.ether.bridge=1
|
||||
if [ X$bridged = XYES ]; then
|
||||
kldload netgraph.ko
|
||||
kldload ng_ether.ko
|
||||
kldload ng_bridge.ko
|
||||
ngctl mkpeer vmnet1: bridge lower link0
|
||||
ngctl name vmnet1:lower vmnet_bridge
|
||||
ngctl connect vmnet_bridge: ${bridge_interface}: link1 lower
|
||||
ngctl connect vmnet_bridge: ${bridge_interface}: link2 upper
|
||||
ngctl msg ${bridge_interface}: setautosrc 0
|
||||
ngctl msg ${bridge_interface}: setpromisc 1
|
||||
ngctl msg vmnet1: setautosrc 0
|
||||
ngctl msg vmnet1: setpromisc 1
|
||||
fi
|
||||
fi
|
||||
echo -n " VMware${bridge}" >&2
|
||||
echo -n " VMware" >&2
|
||||
;;
|
||||
|
||||
stop)
|
||||
@ -67,8 +77,11 @@ stop)
|
||||
if [ $networking -eq 1 ]; then
|
||||
ifconfig vmnet1 down
|
||||
ifconfig vmnet1 delete $host_ip
|
||||
sysctl net.link.ether.bridge_refresh && bridge="_bridge"
|
||||
[ _$bridge != _ ] && sysctl -w net.link.ether.bridge_refresh=1
|
||||
if [ X$bridged = XYES ]; then
|
||||
ngctl shutdown vmnet_bridge:
|
||||
ngctl msg ${bridge_interface}: setautosrc 1
|
||||
ngctl msg ${bridge_interface}: setpromisc 0
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
|
60
emulators/vmware2/scripts/configure
vendored
60
emulators/vmware2/scripts/configure
vendored
@ -8,6 +8,34 @@ netmask=$VMNET_NETMASK
|
||||
title="VMware network options"
|
||||
|
||||
get_network_settings() {
|
||||
bridged="NO"
|
||||
/usr/bin/dialog --title "$title" --clear --yesno \
|
||||
"\n"\
|
||||
"Do you want to use netgraph bridging?\n"\
|
||||
10 50
|
||||
if [ $? -eq 0 ]; then
|
||||
bridged="YES"
|
||||
result=`/usr/bin/dialog --title "$title" --clear --inputbox \
|
||||
"\n"\
|
||||
"To which interface would you\n"\
|
||||
"like to tie the bridge?:"\
|
||||
10 50 "" \
|
||||
2>&1 > /dev/tty`
|
||||
case $? in
|
||||
0)
|
||||
if [ -z "$result" ]; then
|
||||
return 1
|
||||
fi
|
||||
bdg_interface=$result
|
||||
;;
|
||||
1)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
host_ip=192.168.0.1
|
||||
netmask=255.255.255.0
|
||||
else
|
||||
|
||||
result=`/usr/bin/dialog --title "$title" --clear --inputbox \
|
||||
"\n"\
|
||||
"What will be the IP address of your host\n"\
|
||||
@ -46,19 +74,31 @@ get_network_settings() {
|
||||
;;
|
||||
esac
|
||||
return 0;
|
||||
fi
|
||||
}
|
||||
|
||||
do_network() {
|
||||
while true; do
|
||||
get_network_settings
|
||||
|
||||
if [ "X$bridged" != "XYES" ]; then
|
||||
/usr/bin/dialog --title "Confirmation" --clear --yesno \
|
||||
"\n"\
|
||||
"Are the following options correct?\n\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
"Configuration: host only\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
10 50
|
||||
[ $? -eq 0 ] && return 0
|
||||
else
|
||||
/usr/bin/dialog --title "Confirmation" --clear --yesno \
|
||||
"\n"\
|
||||
"Are the following options correct?\n\n"\
|
||||
"Configuration: bridged\n"\
|
||||
"Interface: $bdg_interface\n"\
|
||||
10 50
|
||||
[ $? -eq 0 ] && return 0
|
||||
fi
|
||||
|
||||
/usr/bin/dialog --title "Confirmation" --clear --yesno \
|
||||
"\n"\
|
||||
@ -85,12 +125,22 @@ if [ _$BATCH = _ ]; then
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
networking=1
|
||||
if [ X$bridged = XYES ]; then
|
||||
/usr/bin/dialog --title "$title" --infobox \
|
||||
"\n"\
|
||||
"The following options will be used.\n\n"\
|
||||
"Configuration: bridged\n"\
|
||||
"Interface: $bdg_interface\n"\
|
||||
10 50
|
||||
else
|
||||
/usr/bin/dialog --title "$title" --infobox \
|
||||
"\n"\
|
||||
"The following options will be used.\n\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
"Configuration: host only\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
10 50
|
||||
fi
|
||||
fi
|
||||
else #BATCH
|
||||
[ -f ${WRKDIR}/Makefile.inc.net ] && exit 0
|
||||
@ -100,6 +150,8 @@ fi #BATCH
|
||||
exec > ${WRKDIR}/Makefile.inc.net
|
||||
|
||||
echo '#' `date`
|
||||
echo VMNET_BRIDGED=$bridged
|
||||
echo VMNET_BRIDGED_INTERFACE=$bdg_interface
|
||||
echo VMNET_HOST_IP=$host_ip
|
||||
echo VMNET_NETMASK=$netmask
|
||||
echo VMNET_NETWORKING=$networking
|
||||
|
@ -102,6 +102,8 @@ setoptions:
|
||||
${SED} -e 's;@@PREFIX@@;${PREFIX};' \
|
||||
-e 's;@@LINUXBASE@@;${LINUXBASE};' \
|
||||
-e 's;@@NETWORKING@@;${VMNET_NETWORKING};' \
|
||||
-e 's;@@BRIDGED@@;${VMNET_BRIDGED};' \
|
||||
-e 's;@@BRIDGE_INTF@@;${VMNET_BRIDGED_INTERFACE};' \
|
||||
${FILESDIR}/vmware.sh > ${WRKDIR}/vmware.sh
|
||||
|
||||
${SED} -e 's;@@PREFIX@@;${PREFIX};' \
|
||||
|
@ -24,6 +24,8 @@ vmware_config() {
|
||||
vmware=`vmware_config vmware.fullpath`
|
||||
vmware_libdir=`vmware_config libdir`
|
||||
networking=@@NETWORKING@@
|
||||
bridged=@@BRIDGED@@
|
||||
bridge_interface=@@BRIDGE_INTF@@
|
||||
host_ip=`vmware_config vmnet1.HostOnlyAddress`
|
||||
netmask=`vmware_config vmnet1.HostOnlyNetMask`
|
||||
dev_vmnet1=@@LINUXBASE@@/dev/vmnet1
|
||||
@ -45,7 +47,6 @@ case $1 in
|
||||
start)
|
||||
kldload ${vmware_libdir}/modules/vmmon_${suffix}.ko
|
||||
if [ $networking -eq 1 ]; then
|
||||
sysctl net.link.ether.bridge_refresh && bridge="_bridge"
|
||||
kldload if_tap.ko
|
||||
if [ ! -e $dev_vmnet1 ]; then
|
||||
echo "$dev_vmnet1 does not exist!" >&2
|
||||
@ -54,12 +55,21 @@ start)
|
||||
fi
|
||||
echo -n > $dev_vmnet1
|
||||
ifconfig vmnet1 $host_ip netmask $netmask
|
||||
if [ _$bridge != _ ]; then
|
||||
sysctl -w net.link.ether.bridge_refresh=1
|
||||
sysctl -w net.link.ether.bridge=1
|
||||
if [ X$bridged = XYES ]; then
|
||||
kldload netgraph.ko
|
||||
kldload ng_ether.ko
|
||||
kldload ng_bridge.ko
|
||||
ngctl mkpeer vmnet1: bridge lower link0
|
||||
ngctl name vmnet1:lower vmnet_bridge
|
||||
ngctl connect vmnet_bridge: ${bridge_interface}: link1 lower
|
||||
ngctl connect vmnet_bridge: ${bridge_interface}: link2 upper
|
||||
ngctl msg ${bridge_interface}: setautosrc 0
|
||||
ngctl msg ${bridge_interface}: setpromisc 1
|
||||
ngctl msg vmnet1: setautosrc 0
|
||||
ngctl msg vmnet1: setpromisc 1
|
||||
fi
|
||||
fi
|
||||
echo -n " VMware${bridge}" >&2
|
||||
echo -n " VMware" >&2
|
||||
;;
|
||||
|
||||
stop)
|
||||
@ -67,8 +77,11 @@ stop)
|
||||
if [ $networking -eq 1 ]; then
|
||||
ifconfig vmnet1 down
|
||||
ifconfig vmnet1 delete $host_ip
|
||||
sysctl net.link.ether.bridge_refresh && bridge="_bridge"
|
||||
[ _$bridge != _ ] && sysctl -w net.link.ether.bridge_refresh=1
|
||||
if [ X$bridged = XYES ]; then
|
||||
ngctl shutdown vmnet_bridge:
|
||||
ngctl msg ${bridge_interface}: setautosrc 1
|
||||
ngctl msg ${bridge_interface}: setpromisc 0
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
|
60
emulators/vmware3/scripts/configure
vendored
60
emulators/vmware3/scripts/configure
vendored
@ -8,6 +8,34 @@ netmask=$VMNET_NETMASK
|
||||
title="VMware network options"
|
||||
|
||||
get_network_settings() {
|
||||
bridged="NO"
|
||||
/usr/bin/dialog --title "$title" --clear --yesno \
|
||||
"\n"\
|
||||
"Do you want to use netgraph bridging?\n"\
|
||||
10 50
|
||||
if [ $? -eq 0 ]; then
|
||||
bridged="YES"
|
||||
result=`/usr/bin/dialog --title "$title" --clear --inputbox \
|
||||
"\n"\
|
||||
"To which interface would you\n"\
|
||||
"like to tie the bridge?:"\
|
||||
10 50 "" \
|
||||
2>&1 > /dev/tty`
|
||||
case $? in
|
||||
0)
|
||||
if [ -z "$result" ]; then
|
||||
return 1
|
||||
fi
|
||||
bdg_interface=$result
|
||||
;;
|
||||
1)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
host_ip=192.168.0.1
|
||||
netmask=255.255.255.0
|
||||
else
|
||||
|
||||
result=`/usr/bin/dialog --title "$title" --clear --inputbox \
|
||||
"\n"\
|
||||
"What will be the IP address of your host\n"\
|
||||
@ -46,19 +74,31 @@ get_network_settings() {
|
||||
;;
|
||||
esac
|
||||
return 0;
|
||||
fi
|
||||
}
|
||||
|
||||
do_network() {
|
||||
while true; do
|
||||
get_network_settings
|
||||
|
||||
if [ "X$bridged" != "XYES" ]; then
|
||||
/usr/bin/dialog --title "Confirmation" --clear --yesno \
|
||||
"\n"\
|
||||
"Are the following options correct?\n\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
"Configuration: host only\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
10 50
|
||||
[ $? -eq 0 ] && return 0
|
||||
else
|
||||
/usr/bin/dialog --title "Confirmation" --clear --yesno \
|
||||
"\n"\
|
||||
"Are the following options correct?\n\n"\
|
||||
"Configuration: bridged\n"\
|
||||
"Interface: $bdg_interface\n"\
|
||||
10 50
|
||||
[ $? -eq 0 ] && return 0
|
||||
fi
|
||||
|
||||
/usr/bin/dialog --title "Confirmation" --clear --yesno \
|
||||
"\n"\
|
||||
@ -85,12 +125,22 @@ if [ _$BATCH = _ ]; then
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
networking=1
|
||||
if [ X$bridged = XYES ]; then
|
||||
/usr/bin/dialog --title "$title" --infobox \
|
||||
"\n"\
|
||||
"The following options will be used.\n\n"\
|
||||
"Configuration: bridged\n"\
|
||||
"Interface: $bdg_interface\n"\
|
||||
10 50
|
||||
else
|
||||
/usr/bin/dialog --title "$title" --infobox \
|
||||
"\n"\
|
||||
"The following options will be used.\n\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
"Configuration: host only\n"\
|
||||
"IP address: $host_ip\n"\
|
||||
"Netmask: $netmask\n"\
|
||||
10 50
|
||||
fi
|
||||
fi
|
||||
else #BATCH
|
||||
[ -f ${WRKDIR}/Makefile.inc.net ] && exit 0
|
||||
@ -100,6 +150,8 @@ fi #BATCH
|
||||
exec > ${WRKDIR}/Makefile.inc.net
|
||||
|
||||
echo '#' `date`
|
||||
echo VMNET_BRIDGED=$bridged
|
||||
echo VMNET_BRIDGED_INTERFACE=$bdg_interface
|
||||
echo VMNET_HOST_IP=$host_ip
|
||||
echo VMNET_NETMASK=$netmask
|
||||
echo VMNET_NETWORKING=$networking
|
||||
|
Loading…
Reference in New Issue
Block a user