インターネット接続設定確認と修正
centos7 からはネットワーク設定にNetworkManage を推奨
ネットワークの設定方法
NetworkManagerに付属する「nmtui」と「nmcli」コマンドを使用した変更方法が奨励
GUI経由でネットワーク周りの変更 NetworkManager TUI を起動 [root@falcon21 ~]# nmtui Enter
enp0s25 を選択して、→で<編集> Enter
、→で、編集
Ctrl Z で、停止させ、これを抜ける
設定変更をコマンドベースで実施 [root@falcon21 ~]# nmcli device DEVICE TYPE STATE CONNECTION enp0s25 ethernet 接続済み Profile 1 lo l oopback 管理無し --
IF デバイス情報確認 [root@falcon21 ~]# nmcli device show enp0s25 GENERAL.DEVICE: enp0s25 GENERAL.TYPE: ethernet GENERAL.HWADDR: 78:2B:CB:95:C1:4F GENERAL.MTU: 1500 GENERAL.STATE: 100 (接続済み) GENERAL.CONNECTION: Profile 1 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/2 WIRED-PROPERTIES.CARRIER: オン IP4.ADDRESS[1]: 192.168.2.101/24 IP4.GATEWAY: 192.168.2.1 IP4.ROUTE[1]: dst = 192.168.2.0/24, nh = 0.0.0.0, mt = 100 IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.2.1, mt = 100 IP4.DNS[1]: 192.168.2.1 IP6.ADDRESS[1]: 2405:6585:c600:1100:7574:a24b:81f9:72d3/64 IP6.ADDRESS[2]: fe80::3c2d:2717:33e0:d375/64 IP6.GATEWAY: fe80::b614:89ff:fe06:4bd6 IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 100 IP6.ROUTE[2]: dst = 2405:6585:c600:1100::/64, nh = ::, mt = 100 IP6.ROUTE[3]: dst = ::/0, nh = fe80::b614:89ff:fe06:4bd6, mt = 100 IP6.ROUTE[4]: dst = ff00::/8, nh = ::, mt = 256, table=255 IP6.DNS[1]: 2001:a7ff:5f01::a IP6.DNS[2]: 2001:a7ff:5f01:1::a
Ethernetの接続一覧 [root@falcon21 ~]# nmcli connection NAME UUID TYPE DEVICE Profile 1 8fc7089e-32b4-47b1-9e4f-9974013cc90c ethernet enp0s25 enp0s25 336f917b-65e2-4425-b4e0-f4be224fb184 ethernet --
*** Profileが優先されているのか、
インターフェイスenp0s25 をアクティベイト [root@falcon21 ~]# nmcli connection up enp0s25 接続が正常にアクティベートされました (D-Bus アクティブパス: /org/freedesktop/NetworkManager/ActiveConnection/3)
** Deactive化は、up を down に変更 **
確認 [root@falcon21 ~]# nmcli connection NAME UUID TYPE DEVICE enp0s25 336f917b-65e2-4425-b4e0-f4be224fb184 ethernet enp0s25 Profile 1 8fc7089e-32b4-47b1-9e4f-9974013cc90c ethernet --
*** 緑文字で表示された側がアクティブ ****
IF デバイス情報確認 ・・・接続ネームを切り替えると内容が変わる [root@falcon21 ~]# nmcli device show enp0s25 GENERAL.DEVICE: enp0s25 GENERAL.TYPE: ethernet GENERAL.HWADDR: 78:2B:CB:95:C1:4F GENERAL.MTU: 1500 GENERAL.STATE: 100 (接続済み) GENERAL.CONNECTION: enp0s25 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/3 WIRED-PROPERTIES.CARRIER: オン IP4.ADDRESS[1]: 192.168.2.101/24 IP4.GATEWAY: 192.168.2.1 IP4.ROUTE[1]: dst = 192.168.2.0/24, nh = 0.0.0.0, mt = 100 IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.2.1, mt = 100 IP4.ROUTE[3]: dst = 192.168.0.0/24, nh = 192.168.2.101, mt = 100 IP4.ROUTE[4]: dst = 192.168.10.0/24, nh = 192.168.2.101, mt = 100 IP4.DNS[1]: 192.168.2.1 IP6.ADDRESS[1]: 2405:6585:c600:1100:7a2b:cbff:fe95:c14f/64 IP6.ADDRESS[2]: fe80::7a2b:cbff:fe95:c14f/64 IP6.GATEWAY: fe80::b614:89ff:fe06:4bd6 IP6.ROUTE[1]: dst = ff00::/8, nh = ::, mt = 256, table=255 IP6.ROUTE[2]: dst = fe80::/64, nh = ::, mt = 256 IP6.ROUTE[3]: dst = ::/0, nh = fe80::b614:89ff:fe06:4bd6, mt = 1024 IP6.ROUTE[4]: dst = 2405:6585:c600:1100::/64, nh = ::, mt = 256
resolv.conf が自動的に修正された
enp0s25 をアクティベイトする前 serch flets-west.jp iptvf.jp space nameserver 192.168.2.1 nameserver 2001:a7ff:5f01: :a nameserver 2001:a7ff:5f01:1: a]
enp0s25 をアクティベイトした後 [root@falcon21 ~]# vi /etc/resolv.conf # Generated by NetworkManager search falcon21.space space nameserver 192.168.2.1
インターフェイス接続 connection の詳細情報を表示
[root@falcon21 ~]# nmcli connection show enp0s25
connection.id: enp0s25
connection.uuid: 336f917b-65e2-4425-b4e0-f4be224fb184
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: enp0s25
connection.autoconnect: はい
connection.autoconnect-priority: -999
connection.autoconnect-retries: -1 (default)
connection.auth-retries: -1
connection.timestamp: 1550312159
connection.read-only: いいえ
connection.permissions: --
connection.zone: external
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: -1 (default)
connection.secondaries: --
connection.gateway-ping-timeout: 0
connection.metered: 不明
connection.lldp: default
connection.mdns: -1 (default)
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: いいえ
802-3-ethernet.mac-address: 78:2B:CB:95:C1:4F
802-3-ethernet.cloned-mac-address: 78:2B:CB:95:C1:4F
802-3-ethernet.generate-mac-address-mask:--
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: --
802-3-ethernet.wake-on-lan: default
802-3-ethernet.wake-on-lan-password: --
ipv4.method: manual
ipv4.dns: 192.168.2.1
ipv4.dns-search: falcon21.space
ipv4.dns-options: ""
ipv4.dns-priority: 0
ipv4.addresses: 192.168.2.101/24
ipv4.gateway: 192.168.2.1
ipv4.routes: { ip = 192.168.0.0/24, nh = 192.168.2.101 }; { ip = 192.168.10.0/24, nh = 192.168.2.10
ipv4.route-metric: -1
ipv4.route-table: 0 (unspec)
ipv4.ignore-auto-routes: いいえ
ipv4.ignore-auto-dns: いいえ
ipv4.dhcp-client-id: --
ipv4.dhcp-timeout: 0 (default)
ipv4.dhcp-send-hostname: はい
ipv4.dhcp-hostname: --
ipv4.dhcp-fqdn: --
ipv4.never-default: いいえ
ipv4.may-fail: はい
ipv4.dad-timeout: -1 (default)
ipv6.method: ignore
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: ""
ipv6.dns-priority: 0
ipv6.addresses: --
ipv6.gateway: --
ipv6.routes: --
ipv6.route-metric: -1
ipv6.route-table: 0 (unspec)
ipv6.ignore-auto-routes: いいえ
ipv6.ignore-auto-dns: いいえ
ipv6.never-default: いいえ
ipv6.may-fail: はい
ipv6.ip6-privacy: -1 (unknown)
ipv6.addr-gen-mode: stable-privacy
ipv6.dhcp-duid: --
ipv6.dhcp-send-hostname: はい
ipv6.dhcp-hostname: --
ipv6.token: --
proxy.method: none
proxy.browser-only: いいえ
proxy.pac-url: --
proxy.pac-script: --
GENERAL.NAME: enp0s25
GENERAL.UUID: 336f917b-65e2-4425-b4e0-f4be224fb184
GENERAL.DEVICES: enp0s25
GENERAL.STATE: アクティベート済み
GENERAL.DEFAULT: はい
GENERAL.DEFAULT6: はい
GENERAL.SPEC-OBJECT: --
GENERAL.VPN: いいえ
GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/3
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/2
GENERAL.ZONE: external
GENERAL.MASTER-PATH: --
IP4.ADDRESS[1]: 192.168.2.101/24
IP4.GATEWAY: 192.168.2.1
IP4.ROUTE[1]: dst = 192.168.2.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.2.1, mt = 100
IP4.ROUTE[3]: dst = 192.168.0.0/24, nh = 192.168.2.101, mt = 100
IP4.ROUTE[4]: dst = 192.168.10.0/24, nh = 192.168.2.101, mt = 100
IP4.DNS[1]: 192.168.2.1
IP6.ADDRESS[1]: 2405:6585:c600:1100:7a2b:cbff:fe95:c14f/64
IP6.ADDRESS[2]: fe80::7a2b:cbff:fe95:c14f/64
IP6.GATEWAY: fe80::b614:89ff:fe06:4bd6
IP6.ROUTE[1]: dst = ff00::/8, nh = ::, mt = 256, table=255
IP6.ROUTE[2]: dst = fe80::/64, nh = ::, mt = 256
IP6.ROUTE[3]: dst = ::/0, nh = fe80::b614:89ff:fe06:4bd6, mt = 1024
IP6.ROUTE[4]: dst = 2405:6585:c600:1100::/64, nh = ::, mt = 256
lines 51-105/105 (END)
-------------------------------------
上記のパラメータを修正したい場合の一例を下記に示します。
※IPアドレスを192.168.0.130, GWを192.168.0.1に変更
# nmcli connection modify enp0s25 ipv4.addresses "192.168.0.130/24 192.168.0.1"
※DNSサーバを192.168.0.1と2に変更
# nmcli connection modify enp0s25 ipv4.dns "192.168.0.1 192.168.0.2"
※StaticRouteの追加
# nmcli connection modify enp0s25 ipv4.routes "192.168.17.0/24 192.168.0.1"
上記の設定変更についても、以下のコマンドを実施後、有効となります。
# systemctl restart NetworkManager
[root@falcon21 ~]# systemctl restart NetworkManage
Failed to restart NetworkManage.service: Unit not found.
***/etc/sysconfig/network-scripts/ifcfg-enp0s25を作成するとNetworkManageが無効になるらしい ****
/etc/sysconfig/network-scripts/ifcfg-enp0s25を削除して、
[root@falcon21 ~]# systemctl restart NetworkManager
[root@falcon21 ~]# systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since 土 2019-02-16 21:35:44 JST; 25s ago
Docs: man:NetworkManager(8)
Main PID: 7594 (NetworkManager)
CGroup: /system.slice/NetworkManager.service
└─7594 /usr/sbin/NetworkManager --no-daemon
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.2401] device (enp0s25): state change:...me')
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.2420] device (enp0s25): state change:...me')
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.2427] device (enp0s25): state change:...me')
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.2436] manager: NetworkManager state i...OCAL
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.3086] manager: NetworkManager state i...SITE
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.3088] policy: set 'enp0s25' (enp0s25)... DNS
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.3090] policy: set 'enp0s25' (enp0s25)... DNS
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.3667] device (enp0s25): Activation: s...ted.
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.3674] manager: NetworkManager state i...OBAL
2月 16 21:35:44 falcon21.space NetworkManager[7594]: <info> [1550320544.3701] manager: startup complete
Hint: Some lines were ellipsized, use -l to show in full.
[root@falcon21 ~]# nmtui
*** EthernetProfile 1 を削除 ***
************************************
CentOS6まではネットワーク周りのコマンドとしてifconfig / netstat / arp / routeなどのコマンドが使用されていましたが、
CentOS7からはこれらは非奨励となりました
従来 |
今後 |
ifconfig |
ip addr , ip -s link |
route |
ip route |
arp |
ip neigh |
netstat |
ss |
例えば、ipconfig の代わりに
[root@falcon21 ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 78:2b:cb:95:c1:4f brd ff:ff:ff:ff:ff:ff
inet 192.168.2.101/24 brd 192.168.2.255 scope global noprefixroute enp0s25
valid_lft forever preferred_lft forever
inet6 2405:6585:c600:1100:7a2b:cbff:fe95:c14f/64 scope global mngtmpaddr noprefixroute dynamic
valid_lft 2591820sec preferred_lft 604620sec
inet6 fe80::7a2b:cbff:fe95:c14f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
-------------------------------------------
デバイスごとの処理パケット数の統計値を表すコマンド
[root@falcon21 ~]# ip -s link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped overrun mcast
260304965 15298 0 0 0 0
TX: bytes packets errors dropped carrier collsns
260304965 15298 0 0 0 0
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 78:2b:cb:95:c1:4f brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
839778 9210 0 0 0 74
TX: bytes packets errors dropped carrier collsns
15852138 14559 0 0 0 0
--------------------------------------
netstat -nrに相当するルーティングテーブルを表示するコマンド
[root@falcon21 ~]# ip route
default via 192.168.2.1 dev enp0s25 proto static metric 100
192.168.0.0/24 via 192.168.2.101 dev enp0s25 proto static metric 100
192.168.2.0/24 dev enp0s25 proto kernel scope link src 192.168.2.101 metric 100
192.168.10.0/24 via 192.168.2.101 dev enp0s25 proto static metric 100
Macアドレスの調査などを行うarpコマンドの代替
[root@falcon21 ~]# ip neigh
192.168.2.1 dev enp0s25 lladdr bc:5c:4c:1e:7f:cd REACHABLE
192.168.2.177 dev enp0s25 lladdr 00:a0:b0:f8:e2:2f REACHABLE
fe80::b614:89ff:fe06:4bd6 dev enp0s25 lladdr b4:14:89:06:4b:d6 router STALE
サービスを一覧表示するコマンド
[root@falcon21 ~]# ss -ltu
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 *:sunrpc *:*
udp UNCONN 0 0 127.0.0.1:323 *:*
udp UNCONN 0 0 *:719 *:*
udp UNCONN 0 0 *:mdns *:*
udp UNCONN 0 0 *:50814 *:*
udp UNCONN 0 0 :::sunrpc :::*
udp UNCONN 0 0 ::1:323 :::*
udp UNCONN 0 0 :::719 :::*
tcp LISTEN 0 128 *:sunrpc *:*
tcp LISTEN 0 5 127.0.0.1:cm *:*
tcp LISTEN 0 2 127.0.0.1:findviatv *:*
tcp LISTEN 0 128 *:ssh *:*
tcp LISTEN 0 128 127.0.0.1:ipp *:*
tcp LISTEN 0 100 127.0.0.1:smtp *:*
tcp LISTEN 0 2 *:ms-wbt-server *:*
tcp LISTEN 0 128 :::sunrpc :::*
tcp LISTEN 0 5 ::1:cm :::*
tcp LISTEN 0 128 :::ssh :::*
tcp LISTEN 0 128 ::1:ipp :::*
tcp LISTEN 0 64 :::tcpmux :::*
*** StateのところがUNCONNとなっているのがUDP、LISTENとなっているところがTCP ***
既に通信が確立したものを表示したい場合は-lオプションを外して使用
[root@falcon21 ~]# ss -tu
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp ESTAB 0 0 192.168.2.101:ms-wbt-server 192.168.2.177:62533
tcp ESTAB 0 0 127.0.0.1:cm 127.0.0.1:45018
tcp ESTAB 0 240 192.168.2.101:ssh 192.168.2.177:62566
tcp ESTAB 0 0 127.0.0.1:45018 127.0.0.1:cm
|
-----------------------------------------
hostsファイルを編集
ローカルIP 又は、マックアドアドレスでドメインを登録
[root@falcon21 ~]# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.2.101 falcon21.space anpachi.moe.hm 192.168.2.177 hayato.falcon21.space 00:13:CE:D0:FD:56 inspiron
-------------------------------------------------
ルーティングの確認
[root@falcon21 ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 enp0s25
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s25
ルーティング設定
「192.168.0.0/24 192.168.1.0/24 」ネットワーク宛通信のゲートウェイを「192.168.2.101」に設定
[root@falcon21 ~]# route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.2.101 enp0s25
[root@falcon21 ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 enp0s25
192.168.0.0 192.168.2.101 255.255.255.0 UG 0 0 0 enp0s25
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s25
***** 192.168.1.0 は、現在、使用停止中で、セットできない****
恒久的にルーティングを追加する ルーティング情報を記述
[root@falcon21 ~]# vi /etc/sysconfig/network-scripts/route-enp0s25
192.168.0.0/24 via 192.168.2.101
192.168.10.0/24 via 192.168.2.101
近いうちに使う予定なので、設定しておく
設定反映
[root@falcon21 ~]# service network restart
Restarting network (via systemctl): [ OK ]
|