Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to configure two interfaces in a single Linux Server. As I want to configure eth0 with a static public IP and eth1 with a dhcp service for others.

user-image
Question added by Mubashar Ali , Linux System Administrator , BRM Solutions International
Date Posted: 2014/03/30
Habib Mohammedaman Kahsay
by Habib Mohammedaman Kahsay , Network Engineer I , Mindlance, Inc. - for - Akamai Technologies

go to /etc/sysconfig/network-scripts

 

 

vi ifcfg-eth0

 

and edit the below 

 

DEVICE=eth0

BOOTPROTO=static

HWADDR=xxxxxxxxx (THis is the NIC MAC address)

IPADDR= Your IP

NETMASK= netmask

ONBOOT=yes

 

save and exit this file. 

 

 

 

 

then open ifcfg-eth1 file :

 

vi ifcdfg-eth1

 

DEVICE=eth1

BOOTPROTO=dhcp

HWADDR=xxxxxxxxx (THis is the other NIC MAC address)

ONBOOT=yes

 

restart network services and now it should work fine even at PC restart. 

 

Thanks,

Muhammad Anzar
by Muhammad Anzar , DevOps/DevSecOps Architect , Confidential

Configure in ifcfg-eth0 and ifcfg-eth1 file from /etc/sysconfig/network-scripts

 

For dhcp - put bootproto as dhcp

static - put bootproto as none/static

 

Specify IPADDR=x.x.x.x

GATEWAY=x.x.x.x

DNS1=x.x.x.x

Deleted user
by Deleted user

Hi, 

Make sure before you making any changes to configuration file you have the backup of it and have root login credentails...if you move to this directory point /etc/sysconfig/network-scripts/ there you will find two files 

 

1- ifcfg-eth0

2- ifcfg-eth1

 

cd /etc/sysconfig/network-scripts/

vi ifcfg-eth0

DEVICE=eth0

BOOTPROTO=static

HWADDR=xxxxxxxxx

IPADDR= Your Public IP

NETMASK= specify netmask

ONBOOT=yes

 

save and exit this file. 

 

then open ifcfg-eth1 file :

 

vi ifcdfg-eth1

DEVICE=eth1

BOOTPROTO=dhcp

HWADDR=xxxxxxxxx

ONBOOT=yes

 

make sure you restart network services. 

 

services network restart

 

check that IP information has been updated. use 

 

ifconfig or ethtool eth0 are very usefull commands. 

 

Gul Zaman
by Gul Zaman , Network Administration , vision technologies

you have to configure eth0 by editing the following:  /etc/sysconfig/network-scripts/ifcfg-eth0

and put the static iP address as: 

DEVICE=eth0

HWADDR=

TYPE=Ethernet

ONBOOT=yes

IPV6INIT=

IPADDR=

NETMASK=

BROADCAST=

NETWORK=

 

GATEWAY=

DNS1=

DNS2=

 

and the same as assine a local IP address for eth1 to get ip from DHCP 

add this:

BOOTPROTO=dhcp

 

Ahmad Hourani
by Ahmad Hourani , Purchasing officer , EuroSurplus

I've done this once before on an openBSD.. 

 

I had to simply configure the eth0 with a static ip address, using ifconfig.. then start the dhcpd on eth1.. and edit the routing table to tell the new network where is its gateway.. you'll probably need to look into nameservers if you are using extra services. 

 

gl

More Questions Like This