How do I gain network access to a system for troubleshooting? The network service and/or NetworkManager service are not working. How can I bring networking up to troubleshoot further? How can I bring up an interface for the current boot only?
NetworkManager can potentially interfere with the manual commands if they conflict with settings that NetworkManager has. However, if an IP address only needs to be manually added to an interface that NetworkManager is not managing, and no default gateway or DNS settings need to be changed, then there should not be a conflict. First, confirm if NetworkManager is running with the following command:
# service NetworkManager status
If the default gateway and/or DNS entries need to be changed, NetworkManager can be stopped to avoid interference with their manual configuration:
# service NetworkManager stop
Stopping NetworkManager should not interfere with any DNS entries, default gateway routes, or IP addresses already assigned, at least on RHEL6 and RHEL7 with Ethernet interfaces.
Bringing up the Interface
The following command can be used to bring up an interface with an IP address:
# ip address add [ip_address]/[subnet_prefix] dev [interface]
[ip_address] is replaced with the IP address you wish to assign.
[subnet_prefix] is the shorthand subnet prefix number (such as /24)
[interface] is the interface you want to assign the IP address to.
Configuring the Routing
If there is no default gateway in place, then the system will only be able to reach other systems within the subnet of any interface that has an IP address. The following can be used to check if there is already a default gateway assigned to a working interface:
# ip route show | grep default
To add a default gateway, the following command can be used:
# ip route add default via [gateway_ip_address] dev [interface]
[gateway_ip_address] is the IP address of the default gateway.
[interface] is the interface that is already either on the same subnet as the default gateway or otherwise has a direct route to the gateway.
Configuring Name Resolution
If there is no DNS nameserver in /etc/resolv.conf, then only connections directly to IP addresses will work. To check if there is an existing nameserver in /etc/resolv.conf the following command can be used:
# grep nameserver /etc/resolv.conf
If there are no nameservers in /etc/resolv.conf, one can be temporarily added with the following command:
# echo "nameserver [dns_ip_address]" >> /etc/resolv.conf
[dns_ip_address] is the IP addres of the DNS server to be used.