LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-23-2015, 12:35 AM   #1
rsperson
LQ Newbie
 
Registered: Jul 2015
Posts: 7

Rep: Reputation: Disabled
Need to setup Linux server run 2 nics for different access


I am putting a second nic in my server. I want to have eth0 running - just like a single nic runs now. I want this for remote SSH access.

The second nic eth1, I want to use openvpn for Private Internet Access and have a few other apps running on that nic.

I know that "ANYTHING" is possible with linux

I already have openvpn running and privateinternetaccess works. I just want to split traffic between the 2 nics with the 2 different external IP addresses. Right now I manually start and stop then privateinternetaccess via openvpn. It would be nice to just keep them both up but separate.

Oh and just one router.

I'm not afraid of a little code - it will force me to learn whatever (perl, python, java)

Thanks in advance
 
Old 07-23-2015, 06:34 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,741

Rep: Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745Reputation: 2745
Easy

No code required, just configuration.
Each service has a setting for what port and IP to listen on. Generally, the IP is left undefined or set to 0.0.0.0(IPv4. IPv6 has an equivalent, but I will restrict to IPv4 for this answer.) This means listen on every possible address on the host.
Simply set the IP to the address of the NIC that you want to allow the traffic on. Henceforth the service will listen only on that address and NOT on the other.
 
Old 08-05-2015, 06:52 PM   #3
rsperson
LQ Newbie
 
Registered: Jul 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hmmm... Doing reading and getting more confused then help. The closest thing I found was "Configuring multiple default routes". I was hoping that a simpler solution was available.

I have openvpn running just fine on eth0. I want openvpn on eth1 - and be able to ssh in on eth0. When privateinternetaccess is running with openvpn I can't ssh in - that has a whole other set of issues. I figured a second nic and split out the work would get me the best of both - openvpn and some other apps on eth1 everything else eth0
(OBTW - eth0 is an Intel nic on the motherboard and eth1 is a low price TP-Link TG-3468)

Every time I try to start eth1 with a gateway - i get errors (enabling the dhcp line, stoping and starting seems to clear the errors)

my setup:

ifconfig
br0 Link encap:Ethernet HWaddr 00:25:11:a5:c7:63
inet addr:192.168.1.89 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::225:11ff:fea5:c763/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:254817 errors:0 dropped:0 overruns:0 frame:0
TX packets:243418 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:242631819 (242.6 MB) TX bytes:140117604 (140.1 MB)

eth0 Link encap:Ethernet HWaddr 00:25:11:a5:c7:63
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1162831 errors:0 dropped:0 overruns:0 frame:0
TX packets:256276 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1417583036 (1.4 GB) TX bytes:141846016 (141.8 MB)
Interrupt:20 Memory:fe9c0000-fe9e0000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:34425 errors:0 dropped:0 overruns:0 frame:0
TX packets:34425 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5799654 (5.7 MB) TX bytes:5799654 (5.7 MB)

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.111.1.6 P-t-P:10.111.1.5 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:210456 errors:0 dropped:0 overruns:0 frame:0
TX packets:172276 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:199716023 (199.7 MB) TX bytes:98666199 (98.6 MB)

virbr0 Link encap:Ethernet HWaddr c6:c6:1c:2a:59:07
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


cat 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

# The primary network interface
##### temp changed from auto eth0 to auto br0
auto br0
iface eth0 inet manual

# added 1-18-2015 bridged info
auto br0
iface br0 inet dhcp
#iface br0 inet static
# address 192.168.1.51
# netmask 255.255.255.0
# gateway 192.168.1.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

# added second nic - eth1 7-24-2015
#auto eth1
iface eth1 inet dhcp
#iface eth1 inet static
# address 192.168.1.52
# netmask 255.255.255.0
# network 192.168.1.0
 
Old 09-09-2015, 12:47 AM   #4
rsperson
LQ Newbie
 
Registered: Jul 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
I think I found something I need - Policy routing

I am not quite setup properly BUT.

I think I need to setup policy routing for my eth1 - 192.168.1.53 - all traffic that comes in on this nic needs to go out on this nic

everything else will use eth0 as default (I am bridged and tunneled and the KVM Machines are only for local use and working on eth0)

I plan to SSH in and connect to PLEX on this nic with my router managing the ports.

I just can't seem to find out HOW

I have read page and pages and pages - but everything looks to solve a much more complex issue - I was hoping to find simple

please show me simple.

Thanks
 
Old 09-09-2015, 01:18 AM   #5
Rinndalir
Member
 
Registered: Sep 2015
Posts: 733

Rep: Reputation: Disabled
If I were you I would draw a diagram. Even just on paper. This would help me think it through. What OS?
 
Old 09-09-2015, 06:53 AM   #6
rsperson
LQ Newbie
 
Registered: Jul 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
dual nic policy routing

Ubuntu 14.04.3 LTS
_____________________________
current networking - everything runs/works - I have openvpn running PrivateInternetAccess so I can no longer "see" this box from outside my router - obviously
My first thought was to get openvpn running on the second nic - I scratched that idea since - if it ain't broke don't fix it - keep everything running as is
I will just enable the second nic (192.168.1.53) - and switch my NAT settings from 192.168.1.89 to 192.168.1.53 - and just SSH in that way
changing NAT for Plex as well lets me continue to run openvpn/PIA ans still get to my Plex server from outside.
_____________________________
both nics are connected to the same router/gateway
the 192.168.1.89 is dhcp reserved (no need to change?)
the 192.168.1.53 is static -

Policy routing seems the cleanest answer - without re-doing everything I have running now.
the examples I have seen ALL run on 2 different subnets - reading about multiple default routes
I just want all traffic in on eth0 to go out on eth0 - my setup does that now - eth0 is default

i just want to add a policy that takes all traffic in on eth1 (my SSH and Plex) to go back out on eth1 - its going back out on eth0 by default

I am running KVM (virtual machines) so the br0, virbr0 are setup and working
tun0 is from the openvpn/PIA setup and is also working
eth1 runs when I turn it on - but replies on eth0

I didn't want to get into different subnets for 1 nic if I didn't have to
_____________________________
ifconfig
br0 Link encap:Ethernet HWaddr 00:25:11:a5:c7:63
inet addr:192.168.1.89 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
...

eth0 Link encap:Ethernet HWaddr 00:25:11:a5:c7:63
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
...

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
...

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.166.1.6 P-t-P:10.166.1.5 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
...

virbr0 Link encap:Ethernet HWaddr 12:14:fe:35:f0:d0
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
...
____________________________________________________________________
 
Old 09-09-2015, 10:20 AM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Putting both NICs on the same subnet is just a recipe for problems. Why do you feel you need two NICs on the same subnet in the first place?
 
Old 09-10-2015, 12:05 AM   #8
rsperson
LQ Newbie
 
Registered: Jul 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
2 nics one network

like I said. I have openvpn for PIA running on one nic - eth0 - along with everything else.

I can't SSH into the machine from outside my network on eth0 when openvpn/PIA is running.
I can't access Plex from outside my network if openvpn/PIA is running.

I want to SSH in and have responses going back out on eth1, and use eth1 to access Plex from outside my network.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gateway server - how to configure NICs and iptables to control Internet access tuxmariner Linux - Networking 4 12-11-2012 06:48 PM
How To setup remote access server on Red Hat Enterprise Linux Server release 5.1 bagra Linux - Newbie 5 10-19-2011 07:04 PM
proxy server setup, 2 NICs in same PC gjhicks Linux - Networking 4 04-06-2005 06:38 AM
Setup linux-apache server to access documents on NT server josephswagner Linux - Software 11 04-11-2003 08:35 AM
Multiple NICs Server Setup swa1 Linux - Software 2 07-26-2001 09:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration