Skip to content

Commit 6cb0b68

Browse files
authored
Merge pull request #42133 from ryanborMSFT/patch-24
Added info about second ipconfig using netplan
2 parents f4fb013 + fed9e41 commit 6cb0b68

File tree

1 file changed

+96
-21
lines changed

1 file changed

+96
-21
lines changed

includes/virtual-network-multiple-ip-addresses-os-config.md

Lines changed: 96 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,65 +47,140 @@ ping -S 10.0.0.5 hotmail.com
4747
>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.
4848
4949
### Linux (Ubuntu 14/16)
50-
We recommend looking at the latest the documentation for your Linux distribution.
50+
51+
We recommend looking at the latest documentation for your Linux distribution.
5152

5253
1. Open a terminal window.
5354
2. Make sure you are the root user. If you are not, enter the following command:
5455

55-
```bash
56-
sudo -i
57-
```
56+
```bash
57+
sudo -i
58+
```
5859

5960
3. Update the configuration file of the network interface (assuming ‘eth0’).
6061

6162
* Keep the existing line item for dhcp. The primary IP address remains configured as it was previously.
6263
* Add a configuration for an additional static IP address with the following commands:
6364

64-
```bash
65-
cd /etc/network/interfaces.d/
66-
ls
67-
```
65+
```bash
66+
cd /etc/network/interfaces.d/
67+
ls
68+
```
6869

6970
You should see a .cfg file.
7071
4. Open the file. You should see the following lines at the end of the file:
7172

73+
```bash
74+
auto eth0
75+
iface eth0 inet dhcp
76+
```
77+
78+
5. Add the following lines after the lines that exist in this file:
79+
80+
```bash
81+
iface eth0 inet static
82+
address <your private IP address here>
83+
netmask <your subnet mask>
84+
```
85+
86+
6. Save the file by using the following command:
87+
88+
```bash
89+
:wq
90+
```
91+
92+
7. Reset the network interface with the following command:
93+
94+
```bash
95+
sudo ifdown eth0 && sudo ifup eth0
96+
```
97+
98+
> [!IMPORTANT]
99+
> Run both ifdown and ifup in the same line if using a remote connection.
100+
>
101+
102+
8. Verify the IP address is added to the network interface with the following command:
103+
104+
```bash
105+
ip addr list eth0
106+
```
107+
108+
You should see the IP address you added as part of the list.
109+
110+
### Linux (Ubuntu 18.04+)
111+
112+
Ubuntu 18.04 and above have changed to `netplan` for OS network management. We recommend looking at the latest documentation for your Linux distribution.
113+
114+
1. Open a terminal window.
115+
2. Make sure you are the root user. If you are not, enter the following command:
116+
72117
```bash
73-
auto eth0
74-
iface eth0 inet dhcp
118+
sudo -i
75119
```
76120

77-
5. Add the following lines after the lines that exist in this file:
121+
3. Create a file for the second interface and open it in a text editor:
78122

79123
```bash
80-
iface eth0 inet static
81-
address <your private IP address here>
82-
netmask <your subnet mask>
124+
vi /etc/netplan/60-static.yaml
83125
```
84126

85-
6. Save the file by using the following command:
127+
4. Add the following lines to the file, replacing `10.0.0.6/24` with your IP/netmask:
128+
129+
```bash
130+
network:
131+
version: 2
132+
ethernets:
133+
eth0:
134+
addresses:
135+
- 10.0.0.6/24
136+
```
137+
138+
5. Save the file by using the following command:
86139

87140
```bash
88141
:wq
89142
```
90143

91-
7. Reset the network interface with the following command:
144+
6. Test the changes using [netplan try](http://manpages.ubuntu.com/manpages/cosmic/man8/netplan-try.8.html) to confirm syntax:
92145

93146
```bash
94-
sudo ifdown eth0 && sudo ifup eth0
147+
netplan try
95148
```
96149

97-
> [!IMPORTANT]
98-
> Run both ifdown and ifup in the same line if using a remote connection.
99-
>
150+
> [!NOTE]
151+
> `netplan try` will apply the changes temporarily and roll the changes back after 120 seconds. If there is a loss of connectivity, please wait 120 seconds, and then reconnect. At that time, the changes will have been rolled back.
152+
153+
7. Assuming no issues with `netplan try`, apply the configuration changes:
154+
155+
```bash
156+
netplan apply
157+
```
100158

101159
8. Verify the IP address is added to the network interface with the following command:
102160

103161
```bash
104162
ip addr list eth0
105163
```
106164

107-
You should see the IP address you added as part of the list.
165+
You should see the IP address you added as part of the list. Example:
108166

167+
```bash
168+
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
169+
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
170+
inet 127.0.0.1/8 scope host lo
171+
valid_lft forever preferred_lft forever
172+
inet6 ::1/128 scope host
173+
valid_lft forever preferred_lft forever
174+
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
175+
link/ether 00:0d:3a:8c:14:a5 brd ff:ff:ff:ff:ff:ff
176+
inet 10.0.0.6/24 brd 10.0.0.255 scope global eth0
177+
valid_lft forever preferred_lft forever
178+
inet 10.0.0.4/24 brd 10.0.0.255 scope global secondary eth0
179+
valid_lft forever preferred_lft forever
180+
inet6 fe80::20d:3aff:fe8c:14a5/64 scope link
181+
valid_lft forever preferred_lft forever
182+
```
183+
109184
### Linux (Red Hat, CentOS, and others)
110185

111186
1. Open a terminal window.

0 commit comments

Comments
 (0)