[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Change to 2 interfaces on 1 NIC?



Hi, Mark:

On Monday 27 September 2010 16:54:39 Mark Neidorff wrote:
> Hi all,
>
> I currently have my 6+ year old server (web, e-mail, firewall, local lan)
> running with 2 NICs, one coming from the DSL router (on the 192.168.2.x
> lan) and the other connected to the local lan (192.168.1.x). (all local
> users get their mail, web surfing and firewall services from my box) I only
> use static IP addresses. This server is a big, old and noisy box and I want
> to use a small, quiet mini-itx box in its place.  The new mini-itx box that
> I just bought has only 1 NIC port.

[...]

> This is the way my current 2 NICs are configured (yes, the config is from
> RH, but the concepts are the same):
> #eth0 connects to the router
> DEVICE=eth0
> BOOTPROTO=static
> IPADDR=192.168.2.2
> NETMASK=255.255.255.0
> GATEWAY=192.168.2.1
> ONBOOT=yes
>
> #eth1 connects to the local lan
> DEVICE=eth1
> BOOTPROTO=static
> BROADCAST=192.168.1.255
> IPADDR=192.168.1.1
> NETMASK=255.255.255.0
> NETWORK=192.168.1.0
> ONBOOT=yes
>
> My questions:
> 1.  Are all 3 of the interfaces shown usable, or does the first "auto eth0"
> define the NIC for the others?

You have currently defined only two interfaces; using three is "just" an 
example.  But, yes, multiple definitions for a single physical interface does 
work provided everything is properly configured.

> 2. Can I put an address like 192.168.2.2 for one "iface" (like eth:0) and
> 192.168.1.1 for another (eth0:1) or will this not work, and I will need a
> mini-itx with 2 NICs?

You should define them as eth0 and eth0:0 or, even better, use the "new" 
iptools to define the different IP configs; something like this:

auto eth0
iface eth0 inet static
        address 192.168.2.2
        netmask 255.255.255.0
        gateway 192.168.2.1
	up ip addr add 192.168.1.1/24 dev $IFACE
        down ip addr del 192.168.1.1/32 dev $IFACE
(yes: the netmask from the 'up' and 'down' stanzas are different)

On top of this, you obviously would need to configure ip routing with 
something like:
echo "1" > /proc/sys/net/ipv4/ip_forward 1
And, as needed, iptables rules for NAT'ing, filtering, etc.

This said, I'd counsel that you should not go this path and get two NICs if at 
all possible.  These kind of "two networks on an interface", specially when 
routing/firewalling/nating is involved, is prone to all kinds of weird 
problems (usually related to MAC-broadcasting/redirecting).

Cheers.


Reply to: