Skip to content

Commit a632509

Browse files
committed
Save instructions on how to set IP address from CLI
1 parent feb1226 commit a632509

2 files changed

Lines changed: 190 additions & 0 deletions

File tree

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"azlux",
3030
"blkid",
3131
"blueshade",
32+
"BOOTUP",
3233
"buymeacoffee",
3334
"cachebust",
3435
"Chromecast",
@@ -77,6 +78,7 @@
7778
"enim",
7879
"enmod",
7980
"errorlens",
81+
"ethernets",
8082
"Etiam",
8183
"excep",
8284
"FAANG",
@@ -102,11 +104,14 @@
102104
"headhr",
103105
"hendrerit",
104106
"Hopkinson",
107+
"hotplug",
105108
"huynh",
106109
"hyvor",
107110
"hyvorcolor",
108111
"ibus",
109112
"icmpv",
113+
"iface",
114+
"ifup",
110115
"igmp",
111116
"imperdiet",
112117
"informa",
@@ -173,6 +178,7 @@
173178
"Neetcode",
174179
"neque",
175180
"netfilter",
181+
"netplan",
176182
"newpwd",
177183
"newuser",
178184
"nextprev",
@@ -184,6 +190,7 @@
184190
"noet",
185191
"nojs",
186192
"nologin",
193+
"noqueue",
187194
"noreferrer",
188195
"Nulla",
189196
"nunc",
@@ -220,6 +227,8 @@
220227
"pulvinar",
221228
"pyenv",
222229
"PYTHONTRACEMALLOC",
230+
"qdisc",
231+
"qlen",
223232
"quis",
224233
"ramifica",
225234
"rapide",
@@ -229,6 +238,7 @@
229238
"reflog",
230239
"Replit",
231240
"researchgate",
241+
"resolvconf",
232242
"résumé",
233243
"robjtede",
234244
"Roboto",
@@ -255,6 +265,7 @@
255265
"sodales",
256266
"sollicitudin",
257267
"speci",
268+
"subiquity",
258269
"svgh",
259270
"svgm",
260271
"svgs",
@@ -296,6 +307,7 @@
296307
"utiliza",
297308
"vadimcn",
298309
"varius",
310+
"vbell",
299311
"vehicula",
300312
"velit",
301313
"venenatis",

content/debian/set_ip.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
+++
2+
title = "Set IP"
3+
date = 2025-05-06
4+
extra = { series = "Debian" }
5+
taxonomies = { tags = ["Debian"] }
6+
+++
7+
8+
# Set static IP from CLI on Ubuntu Server 18
9+
10+
Source: <https://www.techrepublic.com/article/how-to-configure-a-static-ip-address-in-ubuntu-server-18-04/>
11+
12+
## Foreword
13+
14+
If editing the flat file isn’t working then check out if there is a netplan config folder.
15+
If there is then that’s likely the way it is being managed.
16+
If it’s not this still may not be the way (doesn't always work).
17+
18+
## Check what configuration files are present
19+
20+
```sh
21+
ls /etc/netplan
22+
```
23+
24+
If there are none present, proceed to create one, otherwise edit the existing one.
25+
Expectation is that the folder exists but not necessarily the file.
26+
If the folder doesn’t exist then likely this is not the way to do it.
27+
28+
## Edit configuration file as needed
29+
30+
### Open config file
31+
32+
NB: `00-installer-config.yaml` is the name of the config file in the example below
33+
34+
```sh
35+
sudo nano /etc/netplan/00-installer-config.yaml
36+
```
37+
38+
### Sample config file
39+
40+
```yml
41+
# This is the network config written by 'subiquity'
42+
network:
43+
ethernets:
44+
ens160:
45+
addresses:
46+
- 192.168.1.5/24
47+
gateway4: 192.168.1.1
48+
nameservers:
49+
addresses:
50+
- 192.168.1.1
51+
version: 2
52+
```
53+
54+
## Apply Changes
55+
56+
### Normal
57+
58+
```sh
59+
sudo netplan apply
60+
```
61+
62+
### Debug
63+
64+
```sh
65+
sudo netplan --debug apply
66+
```
67+
68+
# Set static IP from CLI on Debian 10
69+
70+
Source: <https://linuxconfig.org/how-to-set-a-static-ip-address-on-debian-10-buster>
71+
72+
## Foreword
73+
74+
The source that this was taken from advises you to disable NetworkManager but if you are using a headless server this likely isn’t something you can do as it appears that it is already not in use.
75+
76+
## Install resolvconf (for dns, optional)
77+
78+
```sh
79+
sudo apt install resolvconf
80+
```
81+
82+
## Check what interfaces are configured using
83+
84+
NB: Make a note of which ones are available
85+
86+
```sh
87+
ip a
88+
```
89+
90+
or
91+
92+
```sh
93+
ls /sys/class/net
94+
```
95+
96+
Note where `ens192:` and `ens224:` are below.
97+
98+
```
99+
ip a
100+
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
101+
qlen 1000
102+
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
103+
inet 127.0.0.1/8 scope host lo
104+
valid_lft forever preferred_lft forever
105+
inet6 ::1/128 scope host
106+
valid_lft forever preferred_lft forever
107+
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group
108+
default qlen 1000
109+
link/ether 00:0c:29:b5:2d:0d brd ff:ff:ff:ff:ff:ff
110+
inet 172.20.1.26/16 brd 172.20.255.255 scope global ens192
111+
valid_lft forever preferred_lft forever
112+
inet6 fe80::20c:29ff:feb5:2d0d/64 scope link
113+
valid_lft forever preferred_lft forever
114+
3: ens224: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen
115+
1000
116+
link/ether 00:0c:29:b5:2d:17 brd ff:ff:ff:ff:ff:ff
117+
```
118+
119+
## Edit Config
120+
121+
### Backup Existing Config
122+
123+
```sh
124+
cp /etc/network/interfaces ~/interfaces.old
125+
```
126+
127+
### Update config
128+
129+
Source: <https://wiki.debian.org/NetworkConfiguration>
130+
131+
Edit `/etc/network/interfaces` to set the configuration.
132+
NB: Indented lines use tab. Edit file as needed.
133+
**NB: ENSURE YOU INCLUDE THE LINE WITH AUTO - THAT CONTROLS WHICH INTERFACES ARE STARTED ON BOOTUP AND RESTART OF THE SERVICE.**
134+
Alternatively you can bring up single interfaces using `ifup` after you edit the file without restarting the service.
135+
More info can also be found on the man page: `man interface`
136+
137+
```sh
138+
sudo nano /etc/network/interfaces
139+
```
140+
141+
**See sample file below**
142+
143+
```
144+
# This file describes the network interfaces available on your system
145+
# and how to activate them. For more information, see interfaces(5).
146+
source /etc/network/interfaces.d/*
147+
# The loopback network interface
148+
auto lo
149+
iface lo inet loopback
150+
# The primary network interface
151+
auto ens192
152+
allow-hotplug ens192
153+
iface ens192 inet static
154+
address 172.20.1.26/16
155+
gateway 172.20.1.1
156+
# dns-* options are implemented by the resolvconf package, if installed
157+
dns-nameservers 172.20.1.1
158+
# The secondary network interface
159+
auto ens224
160+
allow-hotplug ens224
161+
iface ens224 inet static
162+
address 10.140.209.237/24
163+
dns-nameservers 10.140.209.10
164+
```
165+
166+
## Restart Services or Just bring up the new interface
167+
168+
```sh
169+
sudo systemctl restart networking
170+
sudo systemctl restart resolvconf
171+
```
172+
173+
or use the `ifup` command to just bring up the interface edited.
174+
Example:
175+
176+
```sh
177+
sudo ifup ens224
178+
```

0 commit comments

Comments
 (0)