Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.
share|improve this question

migrated from serverfault.com Nov 6 '11 at 15:10

This question came from our site for professional system and network administrators.

add comment

2 Answers 2

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 didnt 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!

share|improve this answer
2  
Shouldn't your broadcast be 192.168.0.255? –  Ernestas Sep 9 '13 at 16:10
add comment

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
share|improve this answer
    
How does Ubuntu know which one should it use for traffic? –  Ernestas Sep 9 '13 at 16:11
    
Any reason why some people/tutorials don't include the gateway portion for the second NIC –  puk Nov 13 '13 at 23:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.