Skip to content

Instantly share code, notes, and snippets.

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 mbodo/787edae4be0a341a032e0a00dbf1f1c2 to your computer and use it in GitHub Desktop.
Save mbodo/787edae4be0a341a032e0a00dbf1f1c2 to your computer and use it in GitHub Desktop.
Configuration of static ip with default gateway

Linux - Static ip network configuration with default gateway

RHEL 7 (windows/vmware player/systemd):

1. Log as root, or user which can work with systemctl and edit /etc configuration.

2. Check if NetworkManager.service is running

systemctl status NetworkManager.service

If running then output should look like:

NetworkManager.service - Network Manager
 Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
 Active: active (running) since Mon 2016-09-19 20:04:34 BST; 2s ago
Main PID: 14727 (NetworkManager)
 CGroup: /system.slice/NetworkManager.service
         └─14727 /usr/sbin/NetworkManager --no-daemon

3. If 1. is true, than stop NetworkManager.service, otherwise jump to [4. Disable permanently NetworkManager.service] (#4-disable-permanently-networkmanagerservice).

systemctl stop NetworkManager.service

Check if it's really stopped:

systemctl status NetworkManager.service

Output should look like:

 NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2016-09-19 20:21:22 BST; 9s ago
  Process: 14727 ExecStart=/usr/sbin/NetworkManager --no-daemon (code=exited, status=0/SUCCESS)
 Main PID: 14727 (code=exited, status=0/SUCCESS)

4. Disable permanently NetworkManager.service

systemctl disable NetworkManager.service

5. (Specific for windows) Find VMware Network Adapter VMnet8 configuration.

ipconfig /all

Output (example):

Ethernet adapter VMware Network Adapter VMnet8:

  IPv4 Address. . . . . . . . . . . : 192.168.179.X(Preferred)
  Subnet Mask . . . . . . . . . . . : 255.255.255.0

It's importatnt to know the VMnet8 IP Adress because we will configure our ethernet static IP Address to be on same subnet.

6. Configure ifcfg file e.g /etc/sysconfig/network-scripts/ifcfg-eno16777736

  • Identify your ethernet device ip -d link

  • Example configuration:

    TYPE=Ethernet
    BOOTPROTO=static
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=no
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=eno16777736
    UUID=xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx
    DEVICE=eno16777736
    ONBOOT=yes
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    PREFIX=24
    IPADDR=192.168.179.XXX
    NETMASK=255.255.255.0
    ZONE=public
    

Use:

XXX - replace with number < 254

7. Configure network file /etc/sysconfig/network

NETWORKING=yes
GATEWAY=192.168.179.X

Use:

X - replace with number

8. Configure /etc/resolv.conf file

nameserver 192.168.179.X

Use:

X - replace with same number as in [7. Configure network file /etc/sysconfig/network] (#7-configure-network-file-etcsysconfignetwork)

9. Restart systemd network.service

systemctl restart network.service

Check status:

systemctl restart network.service

Output:
network.service - LSB: Bring up/down networking
 Loaded: loaded (/etc/rc.d/init.d/network)
 Active: active (exited) since Tue 2016-09-20 08:10:02 BST; 52min ago
   Docs: man:systemd-sysv-generator(8)
Process: 5050 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
Process: 5235 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)

Sep 20 08:10:00 osboxes systemd[1]: Starting LSB: Bring up/down n....
Sep 20 08:10:00 osboxes network[5235]: Bringing up loopback interf...
Sep 20 08:10:02 osboxes network[5235]: Bringing up interface eno16...
Sep 20 08:10:02 osboxes systemd[1]: Started LSB: Bring up/down ne....

You should see Bringing up interface eno16.. as that will bind your ethernet device with ip address.

Tip: use journalctl -f in other terminal to see network.service log messages during restart

10. (Optional) Disable IPv6

Configure /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

And again [9. Restart systemd network.service] (#9-restart-systemd-networkservice)

Now you should be able to connect from windows with putty, address 192.168.179.XXX, see [6. Configure ifcfg file e.g /etc/sysconfig/network-scripts/ifcfg-eno16777736] (#6-configure-ifcfg-file-eg-etcsysconfignetwork-scriptsifcfg-eno16777736)

Ubuntu 12.04 (windows/vmware player/upstart):

To configure DNS:

sudo vi /etc/resolvconf/resolv.conf.d/tail

add

nameserver 192.168.179.X

restart resolvconf with:

sudo resolvconf -u

TODO:

  • Complete Ubuntu 12.04 (windows/vmware player/upstart):
  • Add link to related resources
  • Add somewhere notice about VM Network Settings configuration (NAT, Bridged .etc)
  • Configuring Centos to disable Network Manager and use just network service [ https://www.centos.org/forums/viewtopic.php?t=53972 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment