#author("2020-08-22T17:42:44+09:00","default:ryuichi","ryuichi")
#author("2020-08-22T17:43:20+09:00","default:ryuichi","ryuichi")
* Linuxネットワーク設定 [#d528a39f]
** Redhat/CentOS [#v0f2cd86]
*** /etc/sysconfig/network-scripts/ifcfg-eth0 [#md91f9ce]
スタティック
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.0.150
NETMASK=255.255.255.0
ONBOOT=yes
DHCP
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
*** /etc/sysconfig/network [#ica723a9]
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
GATEWAY=192.168.0.1
*** ネットワーク設定変更の反映 [#o3d2f317]
*** ネットワーク設定変更の反映 [#z8af422f]
''RHEL/CentOS''
systemctl reload NetworkManager
''RHEL6/CentOS6''
service network restart
*** 設定確認 [#q48db522]
*** 設定確認 [#k548e810]
''RHEL/CentOS''
ip link show
ip address show
''RHEL6/CentOS6''
ifconfig
*** 参考 [#kcf9cb46]
https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/6/html/deployment_guide/s1-networkscripts-static-routes
** Ubuntu [#w534a5a4]
*** /etc/network/interfaces [#oeb71d92]
スタティック
''スタティック''
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.150
netmask 255.255.255.0
gateway 192.168.0.1
network 192.168.0.0
broardcast 192.168.0.255
DHCP
''DHCP''
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
詳しくはman 5 interfacesを参照する。
*** IPエイリアス debian [#k0f2fdd4]
- /etc/network/interfacesを書き換える。
- eth0(192.168.0.2)にeth0:0(192.168.0.3)を追加する場合、以下。
auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
auto eth0:0
iface eth0:0 inet static
address 192.168.0.3
netmask 255.255.255.0
gateway 192.168.0.1