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

Re: How to configure eth0 with static ip and eth1 dhcp



On 22/02/2014 18:11, Scott Ferguson wrote:
> On 23/02/14 09:58, Stephen Powell wrote:
>> On Sat, 22 Feb 2014 17:22:16 -0500 (EST), Markos wrote:
>>>
>>> I'm trying to configure a machine with two network cards to share 
>>> Internet access to an internal network
>>>
>>> the /etc/network/interface is:
>>>
>>> # The loopback network interface
>>> auto lo
>>> iface lo inet loopback
>>>
>>> auto eth0
>>> iface eth0 inet static
>>>          address 192.168.0.1
>>>          netmask 255.255.255.0
>>>
>>> auto eth1
>>> iface eth1 inet dhcp
>>>
>>> The card eth0 is used as gateway on the internal network with static IP 
>>> 192.168.0.1 and eth1 is connected to the B-890 -53 Huawei modem.
>>>
>>> But the modem do not send an IP during initialization.

You *could* have things connected backwards. Also, you're missing some
configuration details for eth0.

You need to be bridging eth0 and eth1, I think.  It's been ages since I've set
up a PC as a router, because off-the-shelf ones are usually "good enough" at the
routing part (DHCP, DNS, etc can be offloaded, but that's easy, and doesn't
require 2 NICs).

>>>
>>> [...]
>>
> 
> I'm guessing it's a cdc_ether device - probably running a web and dn
> server at 192.168.0.100.  Hopefully the OP will correct my assumption
> (Vendor and Product codes from dmesg?).
> I'm not familiar with that particular model - but I've had to hack Linux
> support for the chipset either side of it (model number).
> 
> 
> Kind regards
> 
> 




He's using a Huawei B-890-53 4G modem/hub[1], and is trying to hook up a *nix
box to act as a router for other devices.


Really rough diagram (from my understanding of the OP) is as follows:

[b-890] <---> [eth0] {missing config?} [eth1] <---> other device(s).

Not really sure why he needs to do this, as the Huawei box has in integrated
DHCP server/router ... but something like this should work:


1. Set eth0 to have a static IP (e.g. 192.168.0.1)[2]
2. Install DHCP onto the *nix box.
3. Set the IP of eth1 to some other subnet[2] (192.168.1.0/24 or a class A or B
   network -- 10.x.x.0/24 or 172.16.x.0/24).
4. Bind DHCP to eth1 (so it answers requests for internal devices)
5. Set up a route from eth1 to eth0, and vice versa.
6. Set up dnsmasq in iptables.
7. hook up "internal" switch, etc.


Now, the downside to this approach is that devices connected to the Wifi AP of
the Huawei device will not be able to communicate with the stuff behind the *nix
server.  An easier solution (IMO) would be something like the following:

1. Install DHCP server on the *nix box.
2. Set eth0 to a static IP address (e.g. 192.168.0.1).
3. Bind DHCP and DNS to eth0.
4. Connect eth0 on the Huawei device to eth0 of the *nix box.
5. Connect eth1 on the Huawei device to a switch (for the other computers).

A setup like this will then put all devices (wired and wireless) on the same
subnet so they can communicate without any issues.

Please note, this is really high level, and I'm probably forgetting some of the
finer details.

-Dan

[1]That's what they call it anyway.

[2] Something like this should work:

auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
[dns-nameservers 208.67.222.222 208.67.220.220] <-- these are openDNS, use your
ISP, some other DNS provider, or your internal nameservers if you'd like.


auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.0.2

eth1 might be wrong, like I said, it's been ages.


Reply to: