Here's a detailed article on setting up a server with two network cards, one with a dynamic IP (DHCP) and the other with a static IP (192.168.0.24). This article is focused on a server running a fresh OS installation (oven@oven).
Setting Up a Server with Two Network Cards: Dynamic IP (DHCP) and Static IP (192.168.0.24)
In this guide, we will walk you through the process of setting up a server with two network cards. One network card will be configured with a dynamic IP (DHCP), while the other will have a static IP (192.168.0.24). This setup is particularly useful in environments where you need to communicate with other devices on the network while also having a public-facing IP.
Prerequisites
Before we begin, ensure that your server is running a fresh OS installation. In this example, we will use oven@oven as our server.
Configuring the Dynamic IP (DHCP)
- Open the network configuration file. On Ubuntu, this file is located at
/etc/network/interfaces.
sudo nano /etc/network/interfaces
- Locate the interface for your network card that will be using DHCP. It will typically look like this:
auto eth0
iface eth0 inet dhcp
- Save and close the file.
Ctrl+X, Y, Enter
- Restart the networking service.
sudo service networking restart
Configuring the Static IP (192.168.0.24)
- Still in the network configuration file, add a new section for the network card that will be using the static IP.
auto eth1
iface eth1 inet static
address 192.168.0.24
netmask 255.255.255.0
gateway 192.168.0.1
- Save and close the file.
Ctrl+X, Y, Enter
- Restart the networking service.
sudo service networking restart
Testing the Setup
- Verify the IP addresses of both network cards.
ifconfig
You should see the dynamic IP assigned by DHCP and the static IP (192.168.0.24) on the respective network cards.
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet [dynamic IP] netmask 255.255.255.0 broadcast [broadcast IP]
ether [MAC address] txqueuelen 1000 (Ethernet)
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.24 netmask 255.255.255.0 broadcast 192.168.0.255
ether [MAC address] txqueuelen 1000 (Ethernet)
That's it! You have successfully set up a server with two network cards, one with a dynamic IP and the other with a static IP (192.168.0.24).
References
This article is intended for educational purposes only. Always ensure to back up your data before making any changes to your server configuration.