[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 23:57, Scott Ferguson wrote:
On 23/02/14 13:09, Markos wrote:
  
On 22-02-2014 20: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.

The IP of modem is 192.168.1.1.

The modem sends the IP address (192.168.0.4) to my laptop by wifi
without problems.

Any suggestions of what I should check?
       
          
I'm afraid that I don't understand the problem.  Is this a traditional
async dial-up modem?  If so, I would expect it to be configured with
ppp,
its interface name would be ppp0, and it would not be listed in
/etc/network/interfaces at all.  I don't get it.

     
        
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


   
      
Dear Scot and Stephen,

I am using this model of modem:

http://www.4glterouter.de/huawei-b890-4g-lte-smart-hub.html
    
Thanks - yes it's the chipset I was expecting.

  
I just tested on another machine and the modem supplied the IP to my
laptop via wireless and IP to a computer (with 1 NIC) via ethernet
without problem.
    
Yes.

  
Tomorrow I'll change the network card (of the machine with 2 NICs) and
test again to see if the problem is the network card.
    

OK - I misunderstood - I didn't realise you had a second card installed
and assumed you'd just noticed the USB modem cable is seen as a NIC, or
that networkmanager had autoconfigured it for you (it should, if you
have a recent version of usb-modeswitch installed).
You don't need the 2nd network card unless you want to duplicate the
routing functionality build into your modem/hub/router. Just connect the
modem to that computer with the USB cable. Make sure you have
usb_modeswitch installed and add the extra line I suggest (the gateway
stanza).

The modem should then be seen as /dev/eth1 by Debian and will be used as
the gateway for your internet. You'll find that resolv.conf will
automagically use the modem as the nameserver .i.e. /etc/resolv.conf
will contain:-
nameserver 192.18.1.1

You don't need to add netmask and broadcast stanzas to
/etc/network/interfaces, you do need to change auto to hot-plug for the
modem (yes it's USB but the system will see it as an eth device).

Any other devices you connect to the modem should automagically (via
DHCP) do the same - and by default will all be able to communicate with
each other.

NOTE: the route output I quoted (in the previous post) is from a box
connected to a similar Huwaei modem in the same situation.

/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

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.0.6
        netmask 255.255.255.0
        gateway 192.168.1.1
        # dns-* options are implemented by the resolvconf package, if
installed

allow-hotplug eth1
iface eth1 inet dhcp
        # you could make this static, but more typing would be involved


NOTE: network and broadcast stanzas are optional

  
Thanks for your attention,
Markos


    
Kind regards


  
Dear Scott Ferguson, Stephen Powell, Dan Purgert, Andrei POPESCU, Pascal Hambourg, Rod James Bio and Rob Owens,

Thanks for your comments.

As I said, I tested the modem at home, and it worked well.

I imagine that the initial problem was related to the network adapter.

The next day I changed the network card and realized the following:

When I changed the network card the system started to assign the address to eth2 the new card and the modem sent the IP address for this card (eth2).

Despite that the /etc/network/interfaces is:

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


Then I replace the second NIC by another one and again the system assigned the number "eth3" for this new card.

And also the modem sent the IP number OK.

Every time I change the card the system increment the number to the interface: eth2, eth3 etc..

I searched on the Web and I think I'll have to edit the file: /etc/udev/rules.d/70-persistent-net.rules

I think I will fix the name as NAME="eth1" to the new NIC

But I will only be able to do this test in the next weekend.

I will post the test results.

Thank you very much,
Markos

Reply to: