RHEL7 の色々
1.ランレベル
デフォルトのランレベル (ランレベルという概念はなくなったらしいが) を確認する。
# systemctl get-default multi-user.target
上記のコマンドの結果とランレベルの紐付けは以下の情報を参照。
# ls -l /lib/systemd/system/runlevel*target lrwxrwxrwx. 1 root root 15 9月 11 2014 /lib/systemd/system/runlevel0.target -> poweroff.target lrwxrwxrwx. 1 root root 13 9月 11 2014 /lib/systemd/system/runlevel1.target -> rescue.target lrwxrwxrwx. 1 root root 17 9月 11 2014 /lib/systemd/system/runlevel2.target -> multi-user.target lrwxrwxrwx. 1 root root 17 9月 11 2014 /lib/systemd/system/runlevel3.target -> multi-user.target lrwxrwxrwx. 1 root root 17 9月 11 2014 /lib/systemd/system/runlevel4.target -> multi-user.target lrwxrwxrwx. 1 root root 16 9月 11 2014 /lib/systemd/system/runlevel5.target -> graphical.target lrwxrwxrwx. 1 root root 13 9月 11 2014 /lib/systemd/system/runlevel6.target -> reboot.target # # ls -l /usr/lib/systemd/system/default.target lrwxrwxrwx. 1 root root 16 9月 11 2014 /usr/lib/systemd/system/default.target -> graphical.target
デフォルトのランレベルの変更手順は以下となる。
OS を再起動すると以下の状態で起動する。
# systemctl get-default multi-user.target # # systemctl set-default graphical.target rm '/etc/systemd/system/default.target' ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target' # # systemctl get-default graphical.target
再起動なしでランレベルを変更するには以下の手順となる。
# runlevel N 5 # # systemctl isolate multi-user.target # # runlevel 5 3
参考情報
http://thinkit.co.jp/story/2014/12/11/5388
2.NIC の設定
まずは、現在の接続とデバイスの状態を確認。
# nmcli c s 名前 UUID タイプ デバイス test01 99c13513-9423-4d09-89a2-1773fd7c6ab6 802-3-ethernet eno33554984 # # nmcli d s デバイス タイプ 状態 接続 eno33554984 ethernet 接続済み test01 eno16777736 ethernet 切断済み -- eno50332208 ethernet 切断済み -- eno67109432 ethernet 切断済み -- lo loopback 管理無し --
続いて、上記の「eno50332208」というデバイスを「eth0」という接続で追加。
※IP アドレスは 「192.168.110.127/24」で、ゲートウェイが「192.168.110.2」となる。
この場合、デフォルトゲートウェイが未設定の場合、この「192.168.110.2」が割り当てられる。
# nmcli con add type ethernet con-name eth0 ifname eno50332208 ip4 192.168.110.127/24 gw4 192.168.110.2 接続 'eth0' (82a1431d-6844-4a8b-bc99-98e790960fbe) が正常に追加されました。 # # nmcli c s 名前 UUID タイプ デバイス test01 99c13513-9423-4d09-89a2-1773fd7c6ab6 802-3-ethernet eno33554984 eth0 82a1431d-6844-4a8b-bc99-98e790960fbe 802-3-ethernet eno50332208 # # nmcli d s デバイス タイプ 状態 接続 eno33554984 ethernet 接続済み test01 eno50332208 ethernet 接続済み eth0 eno16777736 ethernet 切断済み -- eno67109432 ethernet 切断済み -- lo loopback 管理無し --
デバイスの情報を表示。
# nmcli device show eno50332208 libudev: udev_device_new_from_syspath: device 0x7f7784057030 has devpath '/devices/pci0000:00/0000:00:11.0/0000:02:06.0/net/eno50332208' libudev: udev_device_read_db: device 0x7f7784057030 filled with db file data libudev: udev_device_new_from_syspath: device 0x7f778405a490 has devpath '/devices/pci0000:00/0000:00:11.0/0000:02:06.0' libudev: udev_device_read_db: device 0x7f778405a490 filled with db file data libudev: udev_device_new_from_syspath: device 0x7f778405adb0 has devpath '/devices/pci0000:00/0000:00:11.0' libudev: udev_device_read_db: device 0x7f778405adb0 filled with db file data libudev: udev_device_new_from_syspath: device 0x7f778405c120 has devpath '/devices/pci0000:00' libudev: udev_device_new_from_syspath: device 0x7f778405c120 has devpath '/devices/pci0000:00/0000:00:11.0/0000:02:06.0/net/eno50332208' libudev: udev_device_read_db: device 0x7f778405c120 filled with db file data libudev: udev_device_new_from_syspath: device 0x7f778405adb0 has devpath '/devices/pci0000:00/0000:00:11.0/0000:02:06.0' libudev: udev_device_read_db: device 0x7f778405adb0 filled with db file data libudev: udev_device_new_from_syspath: device 0x7f7784057030 has devpath '/devices/pci0000:00/0000:00:11.0' libudev: udev_device_read_db: device 0x7f7784057030 filled with db file data libudev: udev_device_new_from_syspath: device 0x7f778405a490 has devpath '/devices/pci0000:00' GENERAL.デバイス: eno50332208 GENERAL.タイプ: ethernet GENERAL.HWADDR: 00:0C:29:73:63:48 GENERAL.MTU: 1500 GENERAL.状態: 100 (接続済み) GENERAL.接続: eth0 GENERAL.CON パス: /org/freedesktop/NetworkManager/ActiveConnection/22 WIRED-PROPERTIES.キャリア: オン IP4.アドレス[1]: ip = 192.168.110.127/24, gw = 192.168.110.2 IP6.アドレス[1]: ip = fe80::20c:29ff:fe73:6348/64, gw = ::
デバイスの情報 (特定のフィールドのみ) を表示。
# nmcli --fields IP4 device show eno50332208 IP4.アドレス[1]: ip = 192.168.110.127/24, gw = 192.168.110.2
接続の情報を表示。
# nmcli c s eth0 connection.id: eth0 connection.uuid: 82a1431d-6844-4a8b-bc99-98e790960fbe connection.interface-name: eno50332208 connection.type: 802-3-ethernet connection.autoconnect: yes connection.timestamp: 1439647093 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: 自動 802-3-ethernet.s390-subchannels: 802-3-ethernet.s390-nettype: -- 802-3-ethernet.s390-options: ipv4.method: manual ipv4.dns: ipv4.dns-search: ipv4.addresses: { ip = 192.168.110.127/24, gw = 192.168.110.2 } 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 (不明) ipv6.dhcp-hostname: -- GENERAL.名前: eth0 GENERAL.UUID: 82a1431d-6844-4a8b-bc99-98e790960fbe GENERAL.デバイス: eno50332208 GENERAL.状態: アクティベート済み GENERAL.デフォルト: はい GENERAL.デフォルト6: いいえ GENERAL.VPN: いいえ GENERAL.ゾーン: -- GENERAL.DBUS パス: /org/freedesktop/NetworkManager/ActiveConnection/22 GENERAL.CON パス: /org/freedesktop/NetworkManager/Settings/23 GENERAL.スペックオブジェクト: -- GENERAL.マスターパス: -- IP4.アドレス[1]: ip = 192.168.110.127/24, gw = 192.168.110.2 IP6.アドレス[1]: ip = fe80::20c:29ff:fe73:6348/64, gw = ::
接続の情報 (特定のフィールドのみ) を表示。
# nmcli --fields ipv4 connection show eth0 ipv4.method: manual ipv4.dns: ipv4.dns-search: ipv4.addresses: { ip = 192.168.110.127/24, gw = 192.168.110.2 } 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
接続の停止と起動。
# nmcli c show 名前 UUID タイプ デバイス eth0 8c94448c-a235-40b3-9526-3a29f1e627c2 802-3-ethernet eno50332208 test01 cbead119-159c-4b0f-84a5-9bd168cfe338 802-3-ethernet eno16777736 # # nmcli con down eth0 # # nmcli c show 名前 UUID タイプ デバイス eth0 8c94448c-a235-40b3-9526-3a29f1e627c2 802-3-ethernet -- test01 cbead119-159c-4b0f-84a5-9bd168cfe338 802-3-ethernet eno16777736 # # nmcli con up eth0 接続が正常にアクティベートされました (D-Bus アクティブパス: /org/freedesktop/NetworkManager/ActiveConnection/5) # # nmcli c show 名前 UUID タイプ デバイス eth0 8c94448c-a235-40b3-9526-3a29f1e627c2 802-3-ethernet eno50332208 test01 cbead119-159c-4b0f-84a5-9bd168cfe338 802-3-ethernet eno16777736
デフォルトゲートウェイの追加と削除
# ip r default via 192.168.110.2 dev eno50332208 proto static metric 1024 192.168.16.0/24 dev eno16777736 proto kernel scope link src 192.168.16.131 192.168.110.0/24 dev eno50332208 proto kernel scope link src 192.168.110.127 # # ip route del default via 192.168.110.2 dev eno50332208 # # ip r 192.168.16.0/24 dev eno16777736 proto kernel scope link src 192.168.16.131 192.168.110.0/24 dev eno50332208 proto kernel scope link src 192.168.110.127 # # ip route add default via 192.168.110.2 dev eno50332208 # # ip r default via 192.168.110.2 dev eno50332208 192.168.16.0/24 dev eno16777736 proto kernel scope link src 192.168.16.131 192.168.110.0/24 dev eno50332208 proto kernel scope link src 192.168.110.127
IP アドレスの変更
# nmcli --fields ipv4.addresses connection show eth0 ipv4.addresses: { ip = 192.168.110.127/24, gw = 0.0.0.0 } # # nmcli connection modify eth0 ipv4.addresses "192.168.110.128/24" # # nmcli --fields ipv4.addresses connection show eth0 ipv4.addresses: { ip = 192.168.110.128/24, gw = 0.0.0.0 }
参考情報
https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html-single/Networking_Guide/index.html#sec-Static-Routes_and_the_Default_Gateway
http://enakai00.hatenablog.com/entry/20140712/1405139841
http://blog.yuryu.jp/2014/07/networkmanager-nmtui-nmcli.html
http://seesaawiki.jp/internetwiki/d/CentOS7/%A5%CD%A5%C3%A5%C8%A5%EF%A1%BC%A5%AF%C0%DF%C4%EA#content_1
http://thinkit.co.jp/author/271
http://thinkit.co.jp/story/2014/12/25/5412
http://www.school.ctc-g.co.jp/columns/nakai/nakai47.html
https://oss.sios.com/yorozu-blog/rhel6-rhel7change
https://oss.sios.com/yorozu-blog/oss-matome201508
https://oss.sios.com/redhat-ch
http://qiita.com/sion_cojp/items/115e1671fcbc8f214aee