sudo vim /etc/network/interfaces 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 sudo /etc/init.d/networking stop sudo /etc/init.d/networking start # 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 Hi guys, I have an HP hard Server on which I installed Ubuntu server 14.04 LTS. The server has two ethernet cards. I installed Squid proxy server and I am using iptables as a firewall on my ubuntu server. Now I want to place my Server between the router and the switch. This is because I want everyone to go through the proxy server to filter some web sites. I am facing some difficulties in the configuration of the two NIC cards on the ubuntu server. It has two interfaces em1 and em2 to which I want to assign static IP addressses. This is what I have configured so far: ##The primary network interface auto em1 iface em1 inet static address 192.168.1.30 netmask 255.255.255.0 gateway 192.168.1.2 network 192.168.1.0 broadcast 192.168.1.255 ## The secondary network interface auto em2 iface em2 inet static address 192.168.1.31 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 Thank you for your help. I configured the interfaces as follows: # The primary network interface auto em1 iface em1 inet static address 192.168.1.30 netmask 255.255.255.0 gateway 192.168.1.2 network 192.168.1.0 broadcast 192.168.1.255 # The secondary network interface auto em2 iface em2 inet static address 192.168.2.30 network 192.168.2.0 netmask 255.255.255.0 broadcast 192.168.2.255 and iptables as follows: -P INPUT ACCEPT -P FORWARD DROP -P OUTPUT ACCEPT -A FORWARD -i em1 -o em2 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i em2 -o em1 -j ACCEPT -A FORWARD -j LOG now when configuring my laptop, let's say i want to give it the IP 192.168.2.15 then which gateway should I specify? Should I use the server IP 192.168.2.30 as gateway ? Thank you it worked. the gateway for the clients should be the em2 ip address of the server Correct. em1's gateway should be the IP of the router; em2 doesn't need a gateway, and the machines connected to em2 would use em2's IP as the gateway. That way the computers know how to route packets from themselves to the internet and back. In fact, your server is acting as a router now; depending on what you're using for an internet connection and if nothing else is connected to the Cisco router (i.e. wireless clients), you may not need the Cisco at all anymore. For a typical cable internet setup using NAT and DHCP it's easy to set up Ubuntu and iptables to do this. If you install a DHCP server (such as isc-dhcp-server) you can have the clients get IP, gateway and DNS from the server instead of having to set up each client with its own IP, etc. https://unix.stackexchange.com/questions/115893/how-to-enable-two-network-interfaces-both-for-internet-in-ubuntu12-04 auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.10.101.105 gateway 10.10.101.254 netmask 255.255.255.0 auto eth1 iface eth1 inet static address 10.10.101.205 gateway 10.10.101.254 netmask 255.255.255.0 route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.10.101.254 0.0.0.0 UG 100 0 0 eth0 10.10.101.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 10.10.101.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 sudo netstat -tapn | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1180/sshd tcp 0 0 10.10.101.105:22 10.10.18.35:57651 ESTABLISHED 13235/sshd: zjuvlis tcp6 0 0 :::22 :::* LISTEN SSH In order to "access" a server over both IP addresses you've set up you need to make sure that SSH is accepting connections on both and is "bound" to both IP addresses. If SSH is listening on all the IP addresses that are present on your system then you should see it bound to the special IP 0.0.0.0. This means any/all interfaces that are present on the system that have an IP associated with it. sudo netstat -tapn | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3540/sshd tcp6 0 0 :::22 :::* LISTEN 3540/sshd Debugging further When attempting to SSH to this host you could use the command telnet to debug if this host is accepting connections on port 22 (SSH's TCP/IP port) on both IP addresses to confirm that it's accepting connections. You could be getting tripped up by a firewall rule (such as by iptables). To confirm just do these to commands from another host: $ telnet 10.10.101.105 22 -and- $ telnet 10.10.101.205 22 When these work you'll see output like this: Trying 10.10.101.105... Connected to 10.10.101.105. Escape character is '^]'. SSH-2.0-OpenSSH_6.2 My question is that: can you give me an example on how to configure 2 network interfaces in a ubuntu host? I want both 2 network interfaces work, both can access Internet and I can access host from outside via these 2 network interfaces. – user2886717 Feb 20 '14 at 11:39 @user2886717 - when you say acess internet, you mean from the system over either NIC out to the internet right? Because inbound (ssh) seems to be working. – slm♦ Feb 20 '14 at 12:49 yeah, you are right. – user2886717 Feb 20 '14 at 12:57 @user2886717 - what do you expect the outbound traffic to do? The routing rules dictate which interface to use when a packet is being routed. So if you've designated the subnet of NIC #1 (10.10.101.254) as your default gateway (UG in route output) then any packets that don't match the other rules, goes out over that NIC only. If you want to use both of them you'll need to do something more complicated this is my /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 91.121.247.155 netmask 255.255.255.255 broadcast 91.121.247.155 post-up route add 188.165.247.254 dev eth0 post-up route add default gw 188.165.247.254 post-down route del 188.165.247.254 dev eth0 post-down route del default gw 188.165.247.254 auto eth1 iface eth1 inet static address 91.121.247.148 netmask 255.255.255.255 broadcast 91.121.247.148 post-up route add 188.165.247.254 dev eth1 post-up route add default gw 188.165.247.254 post-down route del 188.165.247.254 dev eth1 post-down route del default gw 188.165.247.254 dns-nameservers 213.186.33.99 the problem is 91.121.247.155 is not pingable from outside. and i don't know why. # - Very important - # 1 Answer The problem is that you can't have two 'default' gateways by default. How would The kernel know which interface to use if it's being told to use two different interfaces. A quick search online found a recent post showing how to do it by creating a second routing table. Without knowing what limitations you may be working with, why use two separate interfaces? From the looks of it, these two IPS are actually part of the same block. Why not just use an alias on eth0 for the second IP? If it's for bandwidth reasons you should consider setting up link aggregation(LACP, set up with the bonding kernel module) so both addresses can take advantage of the extra (virtual) nic. Assuming each virtual nic is connected to a separate real NIC (going to the same switch) you would also get redundancy for both IPs should one of the cables get pulled or a card goes bad on the VMware host. you answer was illuminating; i would go with IP aliasing and I do eth0:0. Now there is a couple of questions. first what should i do with the eth1; should I just leave it be. the second Q? is how should i write the directives for eth0:0. post-up /sbin/ifconfig eth0:0 91.121.247.148 netmask 255.255.255.255 broadcast 91.121.247.148 post-down /sbin/ifconfig eth0:0 down is it right? – r004 Nov 29 '13 at 19:53 You'll want to search elsewhere for that unfortunately. I spend my time in the RHEL/CentOS world. This howto looks like it would work. As for eth1, if it is connected to the same switch (I would imagine it is if it's vmware); I'd just shut it down for now. If you want to use bonding later you can but if these two virtual interfaces are connected to the same network under VMware, there's not much point in using it unless you need more throughput (and the VMware host actually has a faster uplink like 10Gbit). Using multiple NICs on Linux http://coderazzi.net/linux/dual_nic_linux.htm