2

I have a CentOS 7 machine that has 2 NICs, eth0 and eth1. I have disabled eth0 (as I won't be needing it for my setup) by editing its config and setting:

ONBOOT="no"

And after I configured eth1 (my lan interface) as following it still won't request DHCP:

DEVICE="eth1"
ONBOOT="yes"
NM_CONTROLLED="no"
BOOTPROTO="dhcp"
IPADDR="10.0.0.5" # This is the IP assigned to this machine on the private network.
NETMASK="255.255.0.0"
IPV6INIT="no"
MTU="1450"

Now every time I reboot the system I have to manually use the command dhclient eth1 to make it get DHCP address. What else can I do to solve this? I thought setting BOOTPROTO was the key!

2 Answers 2

1

If you already set "BOOTPROTO=dhcp", you dont need to give IPADDR, NETMASK and GATEWAY because it will bypass them. And for dhcp, Use like this :

vi /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
NAME=eth1
UUID=ACCORDING_TO_YOURS
DEVICE=eth1
ONBOOT=yes

And after saving file, Just restart the service to cross check.

# systemctl restart network

NOTE : First, check if your network is static or dhcp.

1

You should create 2 virtual interfaces for your second NIC: eth1 itself for DHCP and eth1:1 for your private network.

In config for eth1 (file /etc/sysconfig/network-scripts/ifcfg-eth1) you should use DEVICE="eth1", BOOTPROTO="dhcp" and no IPADDR and NETMASK.

In config for eth1:1 (file /etc/sysconfig/network-scripts/ifcfg-eth1:1) you should configure static parameters for your local private network, such as IPADDR, NETMASK, GATEWAY and (it's important!) DEVICE="eth1:1" and BOOTPROTO="static".

As a result, your configuration files should look something like this:

/etc/sysconfig/network-scripts/ifcfg-eth1:

DEVICE="eth1"
ONBOOT="yes"
NM_CONTROLLED="no"
BOOTPROTO="dhcp"
IPV6INIT="no"
MTU="1450"


/etc/sysconfig/network-scripts/ifcfg-eth1:1:

DEVICE="eth1:1"
ONBOOT="yes"
NM_CONTROLLED="no"
BOOTPROTO="static"
IPADDR="10.0.0.5" # This is the IP assigned to this machine on the private network.
NETMASK="255.255.0.0"
IPV6INIT="no"
MTU="1450"

In this case your system will boot up with right network configuration.

P.S.: If you don't need direct access to your private network 10.0.X.X anymore, you can use only first config file /etc/sysconfig/network-scripts/ifcfg-eth1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .