自分用めも

初心者ちっくなプログラムネタを中心に、自分用の覚え書きをメモっていくための場所です。

CentOS7でのネットワーク設定

vmwareの環境をCentOS6から7に変えたら、コマンドが色々変わっていた。
その設定のメモ。

IP設定

CentOS7をインストール後、NetworkManager(nmtui)で固定IPをふる方法 - Qiita
ifcfgファイルを直接いじるのは非推奨とのこと。
nmtuiというguiつきの設定コマンドを使う。

ファイアウォール

iptablesのconfigファイルが無い…と思ったら
代わりにfirewalldと言うものを使うらしい。

状態確認、起動、停止
systemctl status firewalld
systemctl start firewalld
systemctl stop firewalld

statusは起動中ならactive(running)と表示される。

自動起動確認、設定、解除
systemctl is-enabled firewalld.service
systemctl enable firewalld.service
systemctl disable firewalld.service

CentOS6ではchkconfigで設定するが、7ではsystemctlだそうです。

portを開ける(サービス名指定、port指定)
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=mysql
firewall-cmd --permanent --add-port=80/tcp

# リロードして有効化
firewall-cmd --reload

閉じるのはremove。

SSHのポートを変える

/usr/lib/firewalld/services/ssh.xml
/etc/firewalld/services/ssh.xmlにコピーして、port番号を変更する。
CentOS7のfirewalldでsshのポート番号を変更する方法 - Qiita


その他ネットワーク以外色々
CentOS6, CentOS7 システムコマンド対応表