Manually connecting to a network via terminal

23,132

First of all be sure cable is connected to your laptop (I mean Ubuntu detects that cable is connected)

Second enable eth0 by ifconfig eth0 up.

Wait about 30 second and then see output of ifconfig eth0. If you have not IP address (appears in front of inet addr), use dhclient eth0 to force getting address from DHCP server. If it cannot get IP address use following command to set IP address manually:

ifconfig eth0 192.168.0.10/24

IP address must be in the range of your network address. To find out network address range, see your wife IP address (ifconfig works on MAC OSX too).

Now try to ping your default gateway. If no error occurs, you are connected and have suitable IP address. Just specify your default gateway address by:

route add default gw 192.168.0.1

Don't forget to set DNS server by changing /etc/resolv.conf.

Share:
23,132

Related videos on Youtube

Will
Author by

Will

Updated on September 18, 2022

Comments

  • Will
    Will 8 months

    I currently only have wired internet via a cable modem connected to an Airlink 101 ASW105 switch. It works fine for my wife's mac. However, my laptop does not connect; I've tried connecting via eth0 and tried creating a new wired connection- but both fail to connect.

    It's not a hardware problem with my cables or the network hardware, as my wife's machine has been used to test all cables and ports etc, other than that of my laptop.

    So, how can I go about connecting to this network via commands on the terminal?

    If you need more information please fire away.

    Edit: I added some more info based on the comments. I have only added the Wired devices comments for nm-tool.

    ping -c2 4.2.2.2
    connect: Network is unreachable
    nm-tool
    enter code here
    Device eth0----------------------------
    Type:       Wired
    Driver:     tg3
    State:      disconnected
    Default:    no
    HW Address: 00:22:19:F2:36:3B
    Capabilities:
      Carrier Detect: yes
      Speed:          100 MB/s
    Wired Properties
      Carrier:        on
    
    • Braiam
      Braiam over 9 years
      Are you trying to connect using the network manager? What is the output of nm-tool in the terminal? Do ping -c2 4.2.2.2 works? When you connect the cable, some light in the laptop turns on?
    • Will
      Will over 9 years
      @RaduRădeanu that is for wireless connections
    • Radu Rădeanu
      Radu Rădeanu over 9 years
    • Braiam
      Braiam over 9 years
      @RaduRădeanu no, his problem is more profound than this. NM don't detect the cable at all.
    • SuB
      SuB over 9 years
      put output of ifconfig eth0
    • steeldriver
      steeldriver over 9 years
      Some ISPs limit the number of distinct MAC addresses that are allowed to connect to a cable modem. Since most people connect a single router it's usually not an issue, but with a switched network I wonder if the OP has run into this limit, and the modem itself is blocking the 'third' device? It might be worth trying cloning the Mac's MAC in the wired connection properties.
    • Yoran Jansen
      Yoran Jansen over 5 years
      Try wifi-menu, but you will need to install it from the live dvd / cd