Configuring network interface with Static IP address on RHEL 7

Latest response

I am new to RHEL7 and I am running it in Virtualbox.. Right now its using DCHP but I want it to have the same IP address all the time,

I been using this
https://linuxconfig.org/configuring-network-interface-with-static-ip-address-on-rhel-7

but how do I find out the values for the following:
NETMASK="255.0.0.0"
GATEWAY="10.1.1.1"

Can someone please help.. I am new to this

Responses

Hello JX Smith,

Log into the Virtual Machine, run following command from a terminal (window) ip address show (or in shorthand: ip a)

post the output in the discussion, and one of the forum members will help you out. (It might be me from home later today).

Regards,

Jan Gerrit

[root@rhel73 network-scripts]# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:39:e5:88 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.12/24 brd 192.168.0.255 scope global dynamic enp0s3
       valid_lft 2674sec preferred_lft 2674sec
    inet6 2600:8800:5080:2c50:6d88:7e74:379e:a12a/64 scope global noprefixroute dynamic 
       valid_lft 3598sec preferred_lft 3598sec
    inet6 fe80::dab4:24d:5b6b:5a32/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel73 network-scripts]# 
[root@rhel73 network-scripts]# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:39:e5:88 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.12/24 brd 192.168.0.255 scope global dynamic enp0s3
       valid_lft 2674sec preferred_lft 2674sec
    inet6 2600:8800:5080:2c50:6d88:7e74:379e:a12a/64 scope global noprefixroute dynamic 
       valid_lft 3598sec preferred_lft 3598sec
    inet6 fe80::dab4:24d:5b6b:5a32/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel73 network-scripts]# 

I know added

NETMASK="255.255.255.0”
GATEWAY="192.168.0.1”
IPADDR=“192.168.0.12”

and I don't get any network :(

I hope the lines end with double quotes instead of the a with accent circumflex. How do you manage the network service on your virtual machine?

systemctl restart network or systemctl restart NetworkManager

In the latter case you may need to add the following line to /etc/sysconfig/network-scrips/ifcfg-enp0s3

NM_CONTROLLED=yes

Regards,

Jan Gerrit

I added the line and still no network :(

How did you test your network? When you say "still no network", do you mean the system is not accessible from another system on the same network ? Please explain....

From this output I can say that this is dynamic configuration not static:

inet 192.168.0.12/24 brd 192.168.0.255 scope global dynamic enp0s3

Please send the output of the below commands:

#cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
#route -n

funny thing is that I rebooted today and now it it working..


[jsmith@rhel73 ~]$ ip addr show enp0s3 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:39:e5:88 brd ff:ff:ff:ff:ff:ff inet 192.168.0.12/24 brd 192.168.0.255 scope global enp0s3 valid_lft forever preferred_lft forever inet6 2600:8800:5080:2c50:6d88:7e74:379e:a12a/64 scope global noprefixroute dynamic valid_lft 3598sec preferred_lft 3598sec inet6 fe80::dab4:24d:5b6b:5a32/64 scope link valid_lft forever preferred_lft forever [jsmith@rhel73 ~]$

Warning: do not copy the prompt or other security related information, for the Discussion Forum is semi open. Some information is published on media that are Google searchable.

At least I happy for you that it works now.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.