Created
August 11, 2016 20:40
-
-
Save routerman/5e6252b0c0e6fdc4a0001dd383692f9d to your computer and use it in GitHub Desktop.
Linuxで固定IP設定(設定ファイル・コマンド) ref: http://qiita.com/routerman/items/4d19b3084fa58723830c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ip a #"address"は短縮可 | |
$ ip address show dev eth0 #NIC指定表示 | |
$ ifconfig #起動中のNICを表示 | |
$ ifconfig -a #DOWN中のNICも表示 | |
$ ifconfig eth0 #NIC指定表示 | |
$ ping 192.168.11.1 #ゲートウェイにパケットが届くことを確認 | |
$ ping 8.8.8.8 #外部ネットワークのDNSサーバにパケットが届くことを確認 | |
$ ping google.com #名前解決されることを確認 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/init.d/networking restart | |
or | |
# service networking restart | |
or | |
# systemctl restart networking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/init.d/network restart | |
or | |
# service network restart | |
or | |
# systemctl restart network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ip address add 192.168.11.100/24 dev eth0 | |
# ip link set eth0 up | |
# echo "nameserver 192.168.11.1" >> resolv.conf | |
# echo "nameserver 8.8.8.8" >> resolv.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nmcli connection add type eth0 ifname eth0 con-name eth0 | |
# nmcli connection modify eth0 ipv4.addresses "192.168.11.100/24 192.168.11.1" | |
# nmcli connection modify eth0 ipv4.dns "192.168.11.1 8.8.8.8" | |
# nmcli c down eth0 | |
# nmcli c up eth0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ifconfig eth0 192.168.11.100 | |
# ifconfig eth0 up | |
# echo "nameserver 192.168.11.1" >> resolv.conf | |
# echo "nameserver 8.8.8.8" >> resolv.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ONBOOT=yes #rewrite:no->yes | |
IPADDR=192.168.11.100 | |
PREFIX=24 | |
GATEWAY=192.168.11.1 | |
DNS1=192.168.11.1 | |
DNS2=8.8.8.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto eth0 | |
iface eth0 inet static | |
address 192.168.11.100 | |
netmask 255.255.255.0 | |
gateway 192.168.11.1 | |
dns-nameservers 192.168.11.1 8.8.8.8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment