Changeset 94211 in vbox
- Timestamp:
- Mar 13, 2022 8:40:25 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/Config.kmk
r94210 r94211 80 80 man_VBoxManage-guestproperty.xml \ 81 81 man_VBoxManage-guestcontrol.xml \ 82 man_VBoxManage-metrics.xml 82 man_VBoxManage-metrics.xml \ 83 man_VBoxManage-natnetwork.xml 83 84 84 85 ## List of user manual XML files. -
trunk/doc/manual/en_US/man_VBoxManage-natnetwork.xml
r93477 r94211 20 20 <refentry id="vboxmanage-natnetwork" lang="en"> 21 21 <refentryinfo> 22 <pubdate> September 2019</pubdate>22 <pubdate>$Date$</pubdate> 23 23 <title>VBoxManage natnetwork</title> 24 24 </refentryinfo> … … 32 32 <refname>VBoxManage-natnetwork</refname> 33 33 <refpurpose>create, modify, and manage a NAT network</refpurpose> 34 <refclass> Oracle VM VirtualBox</refclass>34 <refclass>&product-name;</refclass> 35 35 </refnamediv> 36 36 -
trunk/doc/manual/en_US/user_VBoxManage.xml
r94210 r94211 1119 1119 <xi:include href="user_man_VBoxManage-metrics.xml" xpointer="element(/1)" xmlns:xi="http://www.w3.org/2001/XInclude" /> 1120 1120 1121 <sect1 id="vboxmanage-natnetwork"> 1122 1123 <title>VBoxManage natnetwork</title> 1124 1125 <para> 1126 NAT networks use the Network Address Translation (NAT) service, 1127 which works in a similar way to a home router. It groups systems 1128 using it into a network and prevents outside systems from directly 1129 accessing those inside, while letting systems inside communicate 1130 with each other and outside systems using TCP and UDP over IPv4 1131 and IPv6. 1132 </para> 1133 1134 <para> 1135 A NAT service is attached to an internal network. Virtual machines 1136 to make use of one should be attached to it. The name of an 1137 internal network is chosen when the NAT service is created, and 1138 the internal network will be created if it does not already exist. 1139 The following is an example command to create a NAT network: 1140 </para> 1141 1142 <screen>VBoxManage natnetwork add --netname natnet1 --network "192.168.15.0/24" --enable</screen> 1143 1144 <para> 1145 Here, <computeroutput>natnet1</computeroutput> is the name of the 1146 internal network to be used and 1147 <computeroutput>192.168.15.0/24</computeroutput> is the network 1148 address and mask of the NAT service interface. By default, in this 1149 static configuration the gateway will be assigned the address 1150 192.168.15.1, the address after the interface address, though this 1151 is subject to change. 1152 </para> 1153 1154 <para> 1155 To add a DHCP server to the NAT network after creation, run the 1156 following command: 1157 </para> 1158 1159 <screen>VBoxManage natnetwork modify --netname natnet1 --dhcp on</screen> 1160 1161 <para> 1162 The subcommands for <command>VBoxManage natnetwork</command> are 1163 as follows: 1164 </para> 1165 1166 <screen>VBoxManage natnetwork add --netname <name> 1167 [--network <network>] 1168 [--enable|--disable] 1169 [--dhcp on|off] 1170 [--port-forward-4 <rule>] 1171 [--loopback-4 <rule>] 1172 [--ipv6 on|off] 1173 [--port-forward-6 <rule>] 1174 [--loopback-6 <rule>] 1175 </screen> 1176 1177 <para> 1178 <command>VBoxManage natnetwork add</command>: Creates a new 1179 internal network interface, and adds a NAT network service. This 1180 command is a prerequisite for enabling attachment of VMs to the 1181 NAT network. Parameters are as follows: 1182 </para> 1183 1184 <variablelist> 1185 1186 <varlistentry> 1187 <term> 1188 <computeroutput>--netname <name></computeroutput> 1189 </term> 1190 1191 <listitem> 1192 <para> 1193 Where <name> is the name of the new internal network 1194 interface on the host OS. 1195 </para> 1196 </listitem> 1197 </varlistentry> 1198 1199 <varlistentry> 1200 <term> 1201 <computeroutput>--network <network></computeroutput> 1202 </term> 1203 1204 <listitem> 1205 <para> 1206 Where <network> specifies the static or DHCP network 1207 address and mask of the NAT service interface. The default 1208 is a static network address. 1209 </para> 1210 </listitem> 1211 </varlistentry> 1212 1213 <varlistentry> 1214 <term> 1215 <computeroutput>--enable|--disable</computeroutput> 1216 </term> 1217 1218 <listitem> 1219 <para> 1220 Enables and disables the NAT network service. 1221 </para> 1222 </listitem> 1223 </varlistentry> 1224 1225 <varlistentry> 1226 <term> 1227 <computeroutput>--dhcp on|off</computeroutput> 1228 </term> 1229 1230 <listitem> 1231 <para> 1232 Enables and disables a DHCP server specified by 1233 <computeroutput>--netname</computeroutput>. Use of this 1234 option also indicates that it is a DHCP server. 1235 </para> 1236 </listitem> 1237 </varlistentry> 1238 1239 <varlistentry> 1240 <term> 1241 <computeroutput>--port-forward-4 <rule></computeroutput> 1242 </term> 1243 1244 <listitem> 1245 <para> 1246 Enables IPv4 port forwarding, with a rule specified by 1247 <rule>. 1248 </para> 1249 </listitem> 1250 </varlistentry> 1251 1252 <varlistentry> 1253 <term> 1254 <computeroutput>--loopback-4 <rule></computeroutput> 1255 </term> 1256 1257 <listitem> 1258 <para> 1259 Enables the IPv4 loopback interface, with a rule specified 1260 by <rule>. 1261 </para> 1262 </listitem> 1263 </varlistentry> 1264 1265 <varlistentry> 1266 <term> 1267 <computeroutput>--ipv6 on|off</computeroutput> 1268 </term> 1269 1270 <listitem> 1271 <para> 1272 Enables and disables IPv6. The default setting is IPv4, 1273 disabling IPv6 enables IPv4. 1274 </para> 1275 </listitem> 1276 </varlistentry> 1277 1278 <varlistentry> 1279 <term> 1280 <computeroutput>--port-forward-6 <rule></computeroutput> 1281 </term> 1282 1283 <listitem> 1284 <para> 1285 Enables IPv6 port forwarding, with a rule specified by 1286 <rule>. 1287 </para> 1288 </listitem> 1289 </varlistentry> 1290 1291 <varlistentry> 1292 <term> 1293 <computeroutput>--loopback-6 <rule></computeroutput> 1294 </term> 1295 1296 <listitem> 1297 <para> 1298 Enables the IPv6 loopback interface, with a rule specified 1299 by <rule>. 1300 </para> 1301 </listitem> 1302 </varlistentry> 1303 1304 </variablelist> 1305 1306 <screen>VBoxManage natnetwork remove --netname <name> </screen> 1307 1308 <para> 1309 <command>VBoxManage natnetwork remove</command>: Removes a NAT 1310 network service. Parameters are as follows: 1311 </para> 1312 1313 <variablelist> 1314 1315 <varlistentry> 1316 <term> 1317 <computeroutput>--netname <name></computeroutput> 1318 </term> 1319 1320 <listitem> 1321 <para> 1322 Where <name> specifies an existing NAT network 1323 service. Does not remove any DHCP server enabled on the 1324 network. 1325 </para> 1326 </listitem> 1327 </varlistentry> 1328 1329 </variablelist> 1330 1331 <screen>VBoxManage natnetwork modify --netname <name> 1332 [--network <network>] 1333 [--enable|--disable] 1334 [--dhcp on|off] 1335 [--port-forward-4 <rule>] 1336 [--loopback-4 <rule>] 1337 [--ipv6 on|off] 1338 [--port-forward-6 <rule>] 1339 [--loopback-6 <rule>] 1340 </screen> 1341 1342 <para> 1343 <command>VBoxManage natnetwork modify</command>: Modifies an 1344 existing NAT network service. Parameters are as follows: 1345 </para> 1346 1347 <variablelist> 1348 1349 <varlistentry> 1350 <term> 1351 <computeroutput>--netname <name></computeroutput> 1352 </term> 1353 1354 <listitem> 1355 <para> 1356 Where <name> specifies an existing NAT network 1357 service. 1358 </para> 1359 </listitem> 1360 </varlistentry> 1361 1362 <varlistentry> 1363 <term> 1364 <computeroutput>--network <network></computeroutput> 1365 </term> 1366 1367 <listitem> 1368 <para> 1369 Where <network> specifies the new static or DHCP 1370 network address and mask of the NAT service interface. The 1371 default is a static network address. 1372 </para> 1373 </listitem> 1374 </varlistentry> 1375 1376 <varlistentry> 1377 <term> 1378 <computeroutput>--enable|--disable</computeroutput> 1379 </term> 1380 1381 <listitem> 1382 <para> 1383 Enables and disables the NAT network service. 1384 </para> 1385 </listitem> 1386 </varlistentry> 1387 1388 <varlistentry> 1389 <term> 1390 <computeroutput>--dhcp on|off</computeroutput> 1391 </term> 1392 1393 <listitem> 1394 <para> 1395 Enables and disables a DHCP server. If a DHCP server is not 1396 present, using enable adds a new DHCP server. 1397 </para> 1398 </listitem> 1399 </varlistentry> 1400 1401 <varlistentry> 1402 <term> 1403 <computeroutput>--port-forward-4 <rule></computeroutput> 1404 </term> 1405 1406 <listitem> 1407 <para> 1408 Enables IPv4 port forwarding, with a rule specified by 1409 <rule>. 1410 </para> 1411 </listitem> 1412 </varlistentry> 1413 1414 <varlistentry> 1415 <term> 1416 <computeroutput>--loopback-4 <rule></computeroutput> 1417 </term> 1418 1419 <listitem> 1420 <para> 1421 Enables the IPv4 loopback interface, with a rule specified 1422 by <rule>. 1423 </para> 1424 </listitem> 1425 </varlistentry> 1426 1427 <varlistentry> 1428 <term> 1429 <computeroutput>--ipv6 on|off</computeroutput> 1430 </term> 1431 1432 <listitem> 1433 <para> 1434 Enables and disables IPv6. The default setting is IPv4, 1435 disabling IPv6 enables IPv4. 1436 </para> 1437 </listitem> 1438 </varlistentry> 1439 1440 <varlistentry> 1441 <term> 1442 <computeroutput>--port-forward-6 <rule></computeroutput> 1443 </term> 1444 1445 <listitem> 1446 <para> 1447 Enables IPv6 port forwarding, with a rule specified by 1448 <rule>. 1449 </para> 1450 </listitem> 1451 </varlistentry> 1452 1453 <varlistentry> 1454 <term> 1455 <computeroutput>--loopback-6 <rule></computeroutput> 1456 </term> 1457 1458 <listitem> 1459 <para> 1460 Enables IPv6 loopback interface, with a rule specified by 1461 <rule>. 1462 </para> 1463 </listitem> 1464 </varlistentry> 1465 1466 </variablelist> 1467 1468 <screen>VBoxManage natnetwork start --netname <name> 1469 </screen> 1470 1471 <para> 1472 <command>VBoxManage natnetwork start</command>: Starts the 1473 specified NAT network service and any associated DHCP server. 1474 Parameters are as follows: 1475 </para> 1476 1477 <variablelist> 1478 1479 <varlistentry> 1480 <term> 1481 <computeroutput>--netname <name></computeroutput> 1482 </term> 1483 1484 <listitem> 1485 <para> 1486 Where <name> specifies an existing NAT network 1487 service. 1488 </para> 1489 </listitem> 1490 </varlistentry> 1491 1492 </variablelist> 1493 1494 <screen>VBoxManage natnetwork stop --netname <name> 1495 </screen> 1496 1497 <para> 1498 <command>VBoxManage natnetwork stop</command>: Stops the specified 1499 NAT network service and any DHCP server. Parameters are as 1500 follows: 1501 </para> 1502 1503 <variablelist> 1504 1505 <varlistentry> 1506 <term> 1507 <computeroutput>--netname <name></computeroutput> 1508 </term> 1509 1510 <listitem> 1511 <para> 1512 Where <name> specifies an existing NAT network 1513 service. 1514 </para> 1515 </listitem> 1516 </varlistentry> 1517 1518 </variablelist> 1519 1520 <screen>VBoxManage natnetwork list [<pattern>] </screen> 1521 1522 <para> 1523 <command>VBoxManage natnetwork list</command>: Lists all NAT 1524 network services, with optional filtering. Parameters are as 1525 follows: 1526 </para> 1527 1528 <variablelist> 1529 1530 <varlistentry> 1531 <term> 1532 <computeroutput>[<pattern>]</computeroutput> 1533 </term> 1534 1535 <listitem> 1536 <para> 1537 Where <pattern> is an optional filtering pattern. 1538 </para> 1539 </listitem> 1540 </varlistentry> 1541 1542 </variablelist> 1543 1544 </sect1> 1121 <xi:include href="user_man_VBoxManage-natnetwork.xml" xpointer="element(/1)" xmlns:xi="http://www.w3.org/2001/XInclude" /> 1545 1122 1546 1123 <sect1 id="vboxmanage-hostonlyif"> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r94210 r94211 249 249 { "dhcpserver", USAGE_S_NEWCMD, HELP_CMD_DHCPSERVER, handleDHCPServer, 0 }, 250 250 #ifdef VBOX_WITH_NAT_SERVICE 251 { "natnetwork", USAGE_ NATNETWORK, VBMG_CMD_TODO, handleNATNetwork, 0 },251 { "natnetwork", USAGE_S_NEWCMD, HELP_CMD_NATNETWORK, handleNATNetwork, 0 }, 252 252 #endif 253 253 { "extpack", USAGE_S_NEWCMD, HELP_CMD_EXTPACK, handleExtPack, 0 }, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r94210 r94211 119 119 USAGE_I_GUESTSTATS, 120 120 USAGE_I_REPAIRHD, 121 USAGE_NATNETWORK,122 121 USAGE_USBDEVSOURCE, 123 122 /* Insert new entries before this line, but only if it is not an option -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r94210 r94211 641 641 "\n", SEP); 642 642 643 #if defined(VBOX_WITH_NAT_SERVICE)644 if (enmCommand == USAGE_NATNETWORK || enmCommand == USAGE_S_ALL)645 {646 RTStrmPrintf(pStrm,647 "%s natnetwork %s add --netname <name>\n"648 " --network <network>\n"649 " [--enable|--disable]\n"650 " [--dhcp on|off]\n"651 " [--port-forward-4 <rule>]\n"652 " [--loopback-4 <rule>]\n"653 " [--ipv6 on|off]\n"654 " [--port-forward-6 <rule>]\n"655 " [--loopback-6 <rule>]\n\n"656 "%s natnetwork %s remove --netname <name>\n\n"657 "%s natnetwork %s modify --netname <name>\n"658 " [--network <network>]\n"659 " [--enable|--disable]\n"660 " [--dhcp on|off]\n"661 " [--port-forward-4 <rule>]\n"662 " [--loopback-4 <rule>]\n"663 " [--ipv6 on|off]\n"664 " [--port-forward-6 <rule>]\n"665 " [--loopback-6 <rule>]\n\n"666 "%s natnetwork %s start --netname <name>\n\n"667 "%s natnetwork %s stop --netname <name>\n\n"668 "%s natnetwork %s list [<pattern>]\n"669 "\n", SEP, SEP, SEP, SEP, SEP, SEP);670 671 672 }673 #endif674 675 643 #if defined(VBOX_WITH_NETFLT) 676 644 if (enmCommand == USAGE_HOSTONLYIFS || enmCommand == USAGE_S_ALL) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageNATNetwork.cpp
r93701 r94211 208 208 { 209 209 if (a->argc - 1 <= 1) 210 return errorSyntax( USAGE_NATNETWORK,Nat::tr("Not enough parameters"));210 return errorSyntax(Nat::tr("Not enough parameters")); 211 211 212 212 const char *pNetName = NULL; … … 263 263 case 't': // --netname 264 264 if (pNetName) 265 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can only specify --netname only once."));265 return errorSyntax(Nat::tr("You can only specify --netname only once.")); 266 266 pNetName = ValueUnion.psz; 267 267 break; … … 269 269 case 'n': // --network 270 270 if (pPrefixIPv4) 271 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can only specify --network only once."));271 return errorSyntax(Nat::tr("You can only specify --network only once.")); 272 272 pPrefixIPv4 = ValueUnion.psz; 273 273 break; … … 275 275 case 'e': // --enable 276 276 if (enable >= 0) 277 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can specify either --enable or --disable once."));277 return errorSyntax(Nat::tr("You can specify either --enable or --disable once.")); 278 278 enable = 1; 279 279 break; … … 281 281 case 'd': // --disable 282 282 if (enable >= 0) 283 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can specify either --enable or --disable once."));283 return errorSyntax(Nat::tr("You can specify either --enable or --disable once.")); 284 284 enable = 0; 285 285 break; … … 287 287 case 'h': 288 288 if (dhcp != -1) 289 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can specify --dhcp only once."));289 return errorSyntax(Nat::tr("You can specify --dhcp only once.")); 290 290 dhcp = ValueUnion.f; 291 291 break; … … 293 293 case '6': 294 294 if (ipv6 != -1) 295 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can specify --ipv6 only once."));295 return errorSyntax(Nat::tr("You can specify --ipv6 only once.")); 296 296 ipv6 = ValueUnion.f; 297 297 break; … … 299 299 case kNATNetwork_IPv6Prefix: 300 300 if (pPrefixIPv6) 301 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can specify --ipv6-prefix only once."));301 return errorSyntax(Nat::tr("You can specify --ipv6-prefix only once.")); 302 302 pPrefixIPv6 = ValueUnion.psz; 303 303 break; … … 305 305 case kNATNetwork_IPv6Default: // XXX: uwe 306 306 if (ipv6_default != -1) 307 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You can specify --ipv6-default only once."));307 return errorSyntax(Nat::tr("You can specify --ipv6-default only once.")); 308 308 ipv6_default = ValueUnion.f; 309 309 break; … … 315 315 /* deletion */ 316 316 if (enmCode != OP_MODIFY) 317 errorSyntax(USAGE_NATNETWORK, 318 Nat::tr("loopback couldn't be deleted on modified\n")); 317 errorSyntax(Nat::tr("loopback couldn't be deleted on modified\n")); 319 318 if (c == 'L') 320 319 loopback6Offset = -1; … … 327 326 RTGETOPT_REQ_STRING); 328 327 if (RT_FAILURE(vrc)) 329 return errorSyntax(USAGE_NATNETWORK, 330 Nat::tr("Not enough parаmeters\n")); 328 return errorSyntax(Nat::tr("Not enough parаmeters\n")); 331 329 332 330 vLoopback2Delete.push_back(std::string(Addr2Delete.psz)); … … 353 351 int irc = netPfStrToPf(ValueUnion.psz, (c == 'P'), &Pfr); 354 352 if (RT_FAILURE(irc)) 355 return errorSyntax( USAGE_NATNETWORK,Nat::tr("Invalid port-forward rule %s\n"), ValueUnion.psz);353 return errorSyntax(Nat::tr("Invalid port-forward rule %s\n"), ValueUnion.psz); 356 354 357 355 vPf2Add.push_back(Pfr); … … 361 359 /* deletion */ 362 360 if (enmCode != OP_MODIFY) 363 return errorSyntax(USAGE_NATNETWORK, 364 Nat::tr("Port-forward could be deleted on modify\n")); 361 return errorSyntax(Nat::tr("Port-forward could be deleted on modify\n")); 365 362 366 363 RTGETOPTUNION NamePf2DeleteUnion; 367 364 int vrc = RTGetOptFetchValue(&GetState, &NamePf2DeleteUnion, RTGETOPT_REQ_STRING); 368 365 if (RT_FAILURE(vrc)) 369 return errorSyntax( USAGE_NATNETWORK,Nat::tr("Not enough parаmeters\n"));366 return errorSyntax(Nat::tr("Not enough parаmeters\n")); 370 367 371 368 if (strlen(NamePf2DeleteUnion.psz) > PF_NAMELEN) 372 return errorSyntax( USAGE_NATNETWORK,Nat::tr("Port-forward rule name is too long\n"));369 return errorSyntax(Nat::tr("Port-forward rule name is too long\n")); 373 370 374 371 PFNAME2DELETE Name2Delete; … … 382 379 383 380 default: 384 return errorGetOpt( USAGE_NATNETWORK,c, &ValueUnion);381 return errorGetOpt(c, &ValueUnion); 385 382 } 386 383 } 387 384 388 385 if (!pNetName) 389 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You need to specify the --netname option"));386 return errorSyntax(Nat::tr("You need to specify the --netname option")); 390 387 /* verification */ 391 388 switch (enmCode) … … 393 390 case OP_ADD: 394 391 if (!pPrefixIPv4) 395 return errorSyntax( USAGE_NATNETWORK,Nat::tr("You need to specify the --network option"));392 return errorSyntax(Nat::tr("You need to specify the --network option")); 396 393 break; 397 394 case OP_MODIFY: … … 607 604 { 608 605 if (a->argc < 1) 609 return errorSyntax( USAGE_NATNETWORK,Nat::tr("Not enough parameters"));606 return errorSyntax(Nat::tr("Not enough parameters")); 610 607 611 608 RTEXITCODE rcExit; 612 609 if (strcmp(a->argv[0], "modify") == 0) 610 { 611 setCurrentSubcommand(HELP_SCOPE_NATNETWORK_MODIFY); 613 612 rcExit = handleOp(a, OP_MODIFY); 613 } 614 614 else if (strcmp(a->argv[0], "add") == 0) 615 { 616 setCurrentSubcommand(HELP_SCOPE_NATNETWORK_ADD); 615 617 rcExit = handleOp(a, OP_ADD); 618 } 616 619 else if (strcmp(a->argv[0], "remove") == 0) 620 { 621 setCurrentSubcommand(HELP_SCOPE_NATNETWORK_REMOVE); 617 622 rcExit = handleOp(a, OP_REMOVE); 623 } 618 624 else if (strcmp(a->argv[0], "start") == 0) 625 { 626 setCurrentSubcommand(HELP_SCOPE_NATNETWORK_START); 619 627 rcExit = handleOp(a, OP_START); 628 } 620 629 else if (strcmp(a->argv[0], "stop") == 0) 630 { 631 setCurrentSubcommand(HELP_SCOPE_NATNETWORK_STOP); 621 632 rcExit = handleOp(a, OP_STOP); 633 } 622 634 else if (strcmp(a->argv[0], "list") == 0) 635 { 636 setCurrentSubcommand(HELP_SCOPE_NATNETWORK_LIST); 623 637 rcExit = handleNATList(a); 638 } 624 639 else 625 rcExit = errorSyntax( USAGE_NATNETWORK,Nat::tr("Invalid parameter '%s'"), a->argv[0]);640 rcExit = errorSyntax(Nat::tr("Invalid parameter '%s'"), a->argv[0]); 626 641 return rcExit; 627 642 }
Note:
See TracChangeset
for help on using the changeset viewer.