1
2

More than 3 years have passed since last update.

nmcliコマンド備忘録

Last updated at Posted at 2019-05-15

ip alias(IPエイリアス)の追加

[root@localhost ~]# nmcli connection modify eth0 +ipv4.addresses "172.31.2.101/22"
[root@localhost ~]# systemctl restart network.service
[root@localhost ~]# ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 172.31.1.127/22 brd 172.31.3.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 172.31.2.101/22 brd 172.31.3.255 scope global secondary eth0
       valid_lft forever preferred_lft forever

削除したいときは+の部分を-にする

nmcli connection modify eth0 -ipv4.addresses "172.31.2.101/22"

resolv.confの設定

[root@localhost ~]# nmcli connection modify System\ eth0 ipv4.dns "8.8.8.8 8.8.8.4"
[root@localhost ~]# systemctl restart NetworkManager
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.8.4

その他

nmcli c m enp10s0 ipv4.method manual ipv4.address 10.110.2.141/16
nmcli c m enp10s0 connection.autoconnect yes
nmcli c m enp10s0 ipv4.gateway 10.110.0.254
nmcli c m enp10s0 ipv4.dns "180.222.191.16 180.222.191.15 8.8.8.8"

IP変更
nmcli c m enp10s0 ipv4.method manual ipv4.addresses "<IPアドレス>/xx <デフォルトゲートウェイ>"
ifup vpn_nic01


最終手段

↑上記コマンドだとIPがつかない場合、以下で行う
ifcfg vpn_nic01 add 10.10.0.15/16

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2