How do I configure two network adapters in Ubuntu Server?

I have two network adapters. How do I setup both adapters in Ubuntu Server for squid?

  • Adapter 1 (ip=192.168.2.100 subnet 255.255.255.0 default gateway 192.168.2.1)
  • Adapter 2 for my network switch which is connected to my user.

Solution 1:

Had a similar issue with 2/two networking devices on Ubuntu 12.04 and apt-get wouldn't resolve any remote host address however, I was able to accept incoming connections. After tons of searching and coming across this post, I had tried the above once before and didn't seem to work.

Not sure if I had made another change since the first time trying to add the gateway option however, after trying to add the gateway option again I was unable to connect to my Webmin interface, which is assigned/bound to (one ip / one interface), however was able to get apt-get update to resolve domains again and ping remote hosts.

To get Webmin accessible again I removed the gateway option from the network card used for the Webmin interface in the /etc/network/interfaces file.

Not sure if I have some other misconfiguration somewhere else that could be causing that to happen, but for now it works and if I find a better solution I will re-post.

My interfaces file :

  # The loopback network interface
  auto lo eth1 etho
  iface lol inet loopback

  # The Primary network interface
  iface eth1 inet static
           address 192.168.0.3
           netmask 255.255.255.0
           network 192.168.0.0
           gateway 192.168.0.1
           dns-nameservers xx.xx.xx.xx xx.xx.xx.xx

  iface eth0 inet static
           address 192.168.0.4
           netmask 255.255.255.0
           broadcast 255.255.255.255 
           network 192.168.0.0

eth1 is for Apache server and is on-board 10/1000 Mb/s eth0 is an add-in card 10/100 Mb/s for local ssh, webmin, etc...

They appear in that order as well.

Thanks!

Solution 2:

That's difficult to read, but I think you asked how to set up two network cards. Here is some help for static addressing. Edit the interfaces file and restart networking. Use your favorite text editor to...

sudo vim /etc/network/interfaces

And the contents of the file:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.2.100
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1

auto eth1
iface eth1 inet static
address 192.168.2.99
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1

Save and restart networking:

sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start