lost and found ( for me ? )

Fedora 21 : configure static IP addresses with nmcli

Reference
http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Networking_Guide/sec-Connecting_to_a_Network_Using_nmcli.html

Here are some examples of nmcli command.

show current configuration
[root@puppet-agent01 ~]# nmcli g hostname     
puppet-agent01.localdomain
[root@puppet-agent01 ~]#

[root@puppet-agent01 ~]# nmcli g status  
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled
[root@puppet-agent01 ~]#

[root@puppet-agent01 ~]# nmcli c
NAME        UUID                                  TYPE            DEVICE
有線接続 2  8caa837f-af49-469b-b9ba-a7b74ac76c9f  802-3-ethernet  eth1   
有線接続 1  ce127401-9483-4a07-a0a6-fc1026384d81  802-3-ethernet  eth0   
eth0        5f24daa3-5de2-45bd-99e0-3c8480bd8be8  802-3-ethernet  --     
[root@puppet-agent01 ~]#

[root@puppet-agent01 ~]# nmcli d
DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  有線接続 1
eth1    ethernet  connected  有線接続 2
lo      loopback  unmanaged  --         
[root@puppet-agent01 ~]#

[root@puppet-agent01 ~]#
[root@puppet-agent01 ~]# nmcli d show eth0
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         52:54:00:58:41:74
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     有線接続 1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         ip = 192.168.122.234/24, gw = 192.168.122.1
IP4.DNS[1]:                             192.168.122.1
IP6.ADDRESS[1]:                         ip = fe80::5054:ff:fe58:4174/64, gw = ::


configure static IP

at first, add a new connection ( in my case, my-eth0 ), and then apply that(my-eth0) to eth0
[root@puppet-agent01 ~]# nmcli con add con-name my-eth0 ifname eth0 type ethernet ip4 192.168.122.233 gw4 192.168.122.1
Connection 'my-eth0' (49e87994-c320-4f69-b2e9-6e83f3500d8f) successfully added.


[root@puppet-agent01 ~]# nmcli c show
NAME        UUID                                  TYPE            DEVICE
有線接続 2  8caa837f-af49-469b-b9ba-a7b74ac76c9f  802-3-ethernet  eth1   
有線接続 1  ce127401-9483-4a07-a0a6-fc1026384d81  802-3-ethernet  eth0   
eth0        5f24daa3-5de2-45bd-99e0-3c8480bd8be8  802-3-ethernet  --     
my-eth0     49e87994-c320-4f69-b2e9-6e83f3500d8f  802-3-ethernet  --   


[root@puppet-agent01 ~]#
[root@puppet-agent01 ~]# nmcli con mod my-eth0 ipv4.dns "8.8.4.4 8.8.8.8"

[root@puppet-agent01 ~]# nmcli -p c show my-eth0
===============================================================================
                    Connection profile details (my-eth0)
===============================================================================
connection.id:                          my-eth0
connection.uuid:                        49e87994-c320-4f69-b2e9-6e83f3500d8f
connection.interface-name:              eth0
connection.type:                        802-3-ethernet
connection.autoconnect:                 yes
connection.timestamp:                   0
connection.read-only:                   no
connection.permissions:                 
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.secondaries:                 
connection.gateway-ping-timeout:        0
-------------------------------------------------------------------------------
802-3-ethernet.port:                    --
802-3-ethernet.speed:                   0
802-3-ethernet.duplex:                  --
802-3-ethernet.auto-negotiate:          yes
802-3-ethernet.mac-address:             --
802-3-ethernet.cloned-mac-address:      --
802-3-ethernet.mac-address-blacklist:   
802-3-ethernet.mtu:                     auto
802-3-ethernet.s390-subchannels:        
802-3-ethernet.s390-nettype:            --
802-3-ethernet.s390-options:            
-------------------------------------------------------------------------------
ipv4.method:                            manual
ipv4.dns:                               8.8.4.4, 8.8.8.8
ipv4.dns-search:                        
ipv4.addresses:                         { ip = 192.168.122.233/32, gw = 192.168.122.1 }
ipv4.routes:                            
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
-------------------------------------------------------------------------------
ipv6.method:                            auto
ipv6.dns:                               
ipv6.dns-search:                        
ipv6.addresses:                         
ipv6.routes:                            
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.dhcp-hostname:                     --
-------------------------------------------------------------------------------
[root@puppet-agent01 ~]#

bring up eth0 with the connection “my-eth0”
[root@puppet-agent01 ~]# nmcli -p con up "my-eth0" ifname eth0

[root@puppet-agent01 ~]# nmcli d
デバイス  タイプ    状態      接続       
eth0      ethernet  接続済み  my-eth0    
eth1      ethernet  接続済み  有線接続 2
lo        loopback  管理無し  --      

[root@puppet-agent01 ~]# nmcli d show eth0
GENERAL.デバイス:                       eth0
GENERAL.タイプ:                         ethernet
GENERAL.HWADDR:                         52:54:00:58:41:74
GENERAL.MTU:                            1500
GENERAL.状態:                           100 (接続済み)
GENERAL.接続:                           my-eth0
GENERAL.CON パス:                       /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.キャリア:              オン
IP4.アドレス[1]:                        ip = 192.168.122.233/32, gw = 192.168.122.1
IP4.DNS[1]:                             8.8.4.4
IP4.DNS[2]:                             8.8.8.8
IP6.アドレス[1]:                        ip = fe80::5054:ff:fe58:4174/64, gw = ::

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.