Question:
How we can configure a system to use two different networks.
Requirements:
Solution:
- Edit the file
/etc/sysconfig/network
and fill in the values of the variables:
NETWORKING=yes
HOSTNAME=myhost.example.com
Note: If necessary, remove or comment out the variableGATEWAY
. Each NIC will have it's own gateway.
- Edit the file
/etc/sysconfig/network-scripts/ifcfg-eth0
and add the following variables with their corresponding values:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
USERCTL=no
IPADDR=
NETMASK=
GATEWAY=
PEERDNS=yes
DNS1=
DNS2=
- Do the same for the file
/etc/sysconfig/network-scripts/ifcfg-eth1
:
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
USERCTL=no
IPADDR=
NETMASK=
GATEWAY=
PEERDNS=yes
DNS1=
DNS2=
The values between '<' and '>' are dependent on your network.The variablesPEERDNS
,DNS1
andDNS2
are optional. If you have the same DNS servers for both networks, you should put the nameservers IPs in the file/etc/resolv.conf
, and in bothifcfg-eth?
files remove the variablesDNS1
andDNS2
and setPEERDNS=no
.
- Restart the
network
service:
# service network
restart
Thanks!