ネットワークデバイスの名前を確認 (次の例だと enp0s3)
shell
1$ ip addr
2
31: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
4 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5 inet 127.0.0.1/8 scope host lo
6 valid_lft forever preferred_lft forever
7 inet6 ::1/128 scope host
8 valid_lft forever preferred_lft forever
92: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
10 link/ether 08:00:27:9a:c6:b9 brd ff:ff:ff:ff:ff:ff
11 inet 10.0.2.16/32 brd 10.0.2.16 scope global noprefixroute enp0s3
12 valid_lft forever preferred_lft forever
13 inet6 fe80::fc6:db58:db62:a9dd/64 scope link noprefixroute
14 valid_lft forever preferred_lft forever
15
コネクション名を確認 (次の例だと Ethernet)
shell
1$ nmcli c s
2
3NAME UUID TYPE DEVICE
4Ethernet 9abb7c66-05a0-4732-8d02-082c7228640a ethernet enp0s3
5
固定IPを指定
shell
1$ sudo nmcli c m Ethernet ipv4.method manual ipv4.address 10.0.2.17
2
コネクションを down up
shell
1$ sudo nmcli c down Ethernet
2$ sudo nmcli c up Ethernet
3
IPを確認
shell
1$ ip addr
2
31: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
4 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
5 inet 127.0.0.1/8 scope host lo
6 valid_lft forever preferred_lft forever
7 inet6 ::1/128 scope host
8 valid_lft forever preferred_lft forever
92: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
10 link/ether 08:00:27:9a:c6:b9 brd ff:ff:ff:ff:ff:ff
11 inet 10.0.2.17/32 brd 10.0.2.17 scope global noprefixroute enp0s3
12 valid_lft forever preferred_lft forever
13 inet6 fe80::fc6:db58:db62:a9dd/64 scope link noprefixroute
14 valid_lft forever preferred_lft forever
15
「enp0s3」と「Ethernet」は環境によって変わりますので お使いの環境のものに読み替えてください。