March 3, 2022 . 3 MIN READ
| up vote 1 down vote favorite | I have two network adapters. How do I setup both adapters in Ubuntu Server for squid?
server networking
|
|||
active oldest votes
| up vote 2 down vote | 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.0eth1 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!
|
|||
| up vote 1 down vote | 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/interfacesAnd the contents of the file: auto loiface lo inet loopback auto eth0iface eth0 inet staticaddress 192.168.2.100netmask 255.255.255.0network 192.168.2.0broadcast 192.168.2.255gateway 192.168.2.1 auto eth1iface eth1 inet staticaddress 192.200.200.100netmask 255.255.255.0network 192.200.200.0Save and restart networking: sudo /etc/init.d/networking stopsudo /etc/init.d/networking start |
/etc/init.d/networking restart
Date: 2010-04-06 00:00:00 -0400
There are situations when you want or need a second IP on your box, for example when you are installing a firewall (In this case is always better to have two NICs but you can do it with only one)
We will assume you already have a system running and already has one IP, if not you wanna read Define a static IP in Linux.
Now we will add the second IP use the same command specifying a virtual NIC
sudo ifconfig eth0:0 192.168.1.2 netmask 255.255.255.0 up
That’s all, but to make changes permanent, edit the file /etc/network/interfaces
There you may have already have something like this
auto loiface lo inet loopback auto eth0iface eth0 inet static address 10.1.1.2 network 10.1.1.0 netmask 255.255.255.0 broadcast 10.1.1.255 gateway 10.1.1.1
Change it to this:
auto loiface lo inet loopback auto eth0 eth0:0iface eth0 inet static address 10.1.1.2 network 10.1.1.0 netmask 255.255.255.0 broadcast 10.1.1.255 gateway 10.1.1.1 iface eth0:0 inet static address 192.168.1.2 network 192.168.1.0 netmask 255.255.255.0
If you want to specify the gateway also here, proceed this way.
auto loiface lo inet loopback auto eth0 eth0:0iface eth0 inet static address 10.1.1.2 network 10.1.1.0 netmask 255.255.255.0 broadcast 10.1.1.255 gateway 10.1.1.1 up route add default gw 10.1.1.1 down route del default gw 10.1.1.1 #Second IP same NIC iface eth0:0 inet static address 192.168.1.2 network 192.168.1.0 netmask 255.255.255.0
If you liked this article please share it.
Reference: http://askubuntu.com/questions/76065/how-do-i-configure-two-network-adapters-in-ubuntu-server