Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@routerman
Created August 11, 2016 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save routerman/5e6252b0c0e6fdc4a0001dd383692f9d to your computer and use it in GitHub Desktop.
Save routerman/5e6252b0c0e6fdc4a0001dd383692f9d to your computer and use it in GitHub Desktop.
Linuxで固定IP設定(設定ファイル・コマンド) ref: http://qiita.com/routerman/items/4d19b3084fa58723830c
$ 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 #名前解決されることを確認
# /etc/init.d/networking restart
or
# service networking restart
or
# systemctl restart networking
# /etc/init.d/network restart
or
# service network restart
or
# systemctl restart network
# 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
# 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
# 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
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
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