@@ -444,44 +444,62 @@ ip route add default via 10.0.0.1 dev eth2 table custom
444
444
<details>
445
445
<summary>Expand</summary>
446
446
447
+ We recommend looking at the latest documentation for your Linux distribution.
448
+
447
449
1. Open a terminal window.
448
- 1. Make sure you' re the root user. If you are not, enter the following command:
450
+
451
+ 2. Ensure you' re the root user. If you aren' t, enter the following command:
449
452
450
453
```bash
451
454
sudo -i
452
455
```
453
456
454
- 1 . Update the configuration file of the network interface (assuming ‘eth0’).
457
+ 3 . Update the configuration file of the network interface (assuming ** ‘eth0’** ).
455
458
456
- * Open the network interface file using below command:
459
+ * Keep the existing line item for dhcp. The primary IP address remains configured as it was previously.
460
+
461
+ * Add a configuration for an additional static IP address with the following commands:
457
462
458
463
```bash
459
- vi /etc/network/interfaces
464
+ cd /etc/network/interfaces.d/
465
+ ls
460
466
```
461
467
462
- * You should see the following lines at the end of the file:
468
+ You should see a .cfg file.
463
469
464
- ` ` ` bash
465
- auth eth0
466
- iface eth0 inet dhcp
467
- ` ` `
470
+ 4. Open the file. You should see the following lines at the end of the file:
468
471
469
- * Keep the existing line item for dhcp as it is. The primary IP address remains configured as it was previously.
470
- * Add the following lines after the lines that exist in this file:
472
+ ```bash
473
+ auto eth0
474
+ iface eth0 inet dhcp
475
+ ```
471
476
472
- ` ` ` bash
473
- iface eth0 inet static
474
- address < your private IP address here>
475
- netmask < your subnet mask>
476
- ` ` `
477
+ 5. Add the following lines after the lines that exist in the file. Replace **`10.1.0.5`** with your private IP address and subnet mask.
477
478
478
- 1. Save the file by using the following command:
479
+ ```bash
480
+ iface eth0 inet static
481
+ address 10.1.0.5
482
+ netmask 255.255.255.0
483
+ ```
484
+
485
+ To add additional private IP addresses, edit the file and add the new private IP addresses on subsequent lines:
486
+
487
+ ```bash
488
+ iface eth0 inet static
489
+ address 10.1.0.5
490
+ netmask 255.255.255.0
491
+ iface eth0 inet static
492
+ address 10.1.0.6
493
+ netmask 255.255.255.0
494
+ ```
495
+
496
+ 6. Save the file by using the following command:
479
497
480
498
```bash
481
- :wq!
499
+ :wq
482
500
```
483
501
484
- 1 . Restart networking services for the changes to take effect. For Debian 8 and above, this can be done using below command :
502
+ 7 . Restart networking services for the changes to take effect. For Debian 8 and above, this can be done using below command :
485
503
486
504
```bash
487
505
systemctl restart networking
@@ -492,29 +510,53 @@ ip route add default via 10.0.0.1 dev eth2 table custom
492
510
service networking restart
493
511
```
494
512
495
- 1 . Verify that the IP address is added to the network interface with the following command:
513
+ 8 . Verify the IP address is added to the network interface with the following command:
496
514
497
515
```bash
498
516
ip addr list eth0
517
+ ```
518
+
519
+ You should see the IP address you added as part of the list. Example:
520
+
521
+ ```bash
522
+ 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
523
+ link/ether 00:0d:3a:04:45:16 brd ff:ff:ff:ff:ff:ff
524
+ inet 10.1.0.5/24 brd 10.1.0.255 scope global eth0
525
+ valid_lft forever preferred_lft forever
526
+ inet 10.1.0.6/24 brd 10.1.0.255 scope global secondary eth0
527
+ valid_lft forever preferred_lft forever
528
+ inet 10.1.0.4/24 brd 10.1.0.255 scope global secondary eth0
529
+ valid_lft forever preferred_lft forever
530
+ inet6 fe80::20d:3aff:fe04:4516/64 scope link
531
+ valid_lft forever preferred_lft forever
499
532
```
500
533
501
- You should see the IP address you added as part of the list. Example:
534
+ #### Validation (Debian GNU/Linux)
535
+
536
+ To ensure you' re able to connect to the internet from your secondary IP configuration via the public IP associated with it, use the following command:
502
537
503
538
` ` ` bash
504
- 1: lo: < LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
505
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
506
- inet 127.0.0.1/8 scope host lo
507
- valid_lft forever preferred_lft forever
508
- inet6 ::1/128 scope host
509
- valid_lft forever preferred_lft forever
510
- 2: eth0: < BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
511
- link/ether 00:0d:3a:1d:1d:64 brd ff:ff:ff:ff:ff:ff
512
- inet 10.2.0.5/24 brd 10.2.0.255 scope global eth0
513
- valid_lft forever preferred_lft forever
514
- inet 10.2.0.6/24 brd 10.2.0.255 scope global secondary eth0
515
- valid_lft forever preferred_lft forever
516
- inet6 fe80::20d:3aff:fe1d:1d64/64 scope link
517
- valid_lft forever preferred_lft forever
518
- ` ` `
539
+ ping -I 10.1.0.5 outlook.com
540
+ ` ` `
541
+
542
+ > [! NOTE]
543
+ > For secondary IP configurations, you can only ping to the Internet if the configuration has a public IP address associated with it. For primary IP configurations, a public IP address is not required to ping to the Internet.
544
+
545
+ For Linux VMs, when attempting to validate outbound connectivity from a secondary NIC, you may need to add appropriate routes. See appropriate documentation for your Linux distribution. The following is one method to accomplish this:
546
+
547
+ ` ` ` bash
548
+ echo 150 custom >> /etc/iproute2/rt_tables
549
+
550
+ ip rule add from 10.1.0.5 lookup custom
551
+ ip route add default via 10.1.0.1 dev eth2 table custom
552
+ ` ` `
553
+
554
+ - Ensure to replace:
555
+
556
+ - ** 10.1.0.5** with the private IP address that has a public IP address associated to it
557
+
558
+ - ** 10.1.0.1** to your default gateway
559
+
560
+ - ** eth2** to the name of your secondary NIC
519
561
520
562
< /details>
0 commit comments