Quick and dirty way to properly set a static IP address on various UNIX-like systems.
Edit /etc/network/interfaces
. The dns-* entries are needed if using resolvconf.
auto eth0 iface eth0 inet static address 172.20.88.100 netmask 255.255.255.0 network 172.20.88.0 broadcast 172.20.88.255 gateway 172.20.88.1 dns-nameservers 10.0.0.53 10.0.1.53 8.8.8.8 dns-search blakhole-networks.com dns-domain blakhole-networks.comRestart the networking service using
sudo /etc/init.d/networking restart
or just reboot to take effect.
Edit /etc/rc.conf
and add lines in for each interface that needs static addressing. The following example addes IPv4 and IPv6 addresses to the em0 and em1 interfaces.
ifconfig_em0=" inet 172.20.1.5 netmask 0xffffff00" ifconfig_em0_ipv6=" inet6 fd69:dead:d00d:10::5 prefixlen 64" ifconfig_em1=" inet 172.20.5.5 netmask 0xffffff00 mtu 8192" ifconfig_em1_ipv6=" inet6 fd69:dead:d00d:5::5 prefixlen 64" defaultrouter="172.20.1.1" ipv6_defaultrouter="fd69:dead:d00d:10::1"
Restart by running /etc/rc.d/netif restart
as root.
Change directory to /etc/sysconfig/network-scripts/
and edit the ifcfg-
file for each network interface to be configured. The following example is for the eth0 interface, and adds IPv4 and IPv6 addresses:
DEVICE="eth0" BOOTPROTO="static" DNS1="127.0.0.1" GATEWAY="10.0.0.1" HWADDR="00:16:3E:00:18:1A" IPADDR="10.0.0.53" NETMASK="255.255.255.0" BROADCAST="10.0.0.255" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6ADDR="fd69:dead:d00d:0053::53" IPV6ADDR_SECONDARIES="2001:470:9995:53::53" IPV6_DEFAULTGW="fd69:dead:d00d:0053::1" NM_CONTROLLED="no" ONBOOT="yes"Changes take effect by running
service network restart
as root.