Saturday, January 5, 2013

Using WiFi and network cable at the same time in Ubuntu

Did you ever have to switch between WiFi and network cable several times a day? If yes, than this blog post is for you.

DISCLAIMER: Check your security policy before trying out solutions from this blog post.

Actually, it does not have to be a WiFi and a network cable. It can be two WiFi connections or two network cable connections. The point is, that you have 2 (or more) network interfaces.

Usually, I have this situation when I need to use intranet resources, which are available for local network and this network has "issues" with connecting to outside world.

By default, Ubuntu allows you to have multiple network connections at the same time. The problem is, that it needs some help on deciding which one to use in certain circumstances.

On this screenshot you can see two active connections:

"Wired connection 1" - default name for wired network connections in Ubuntu. Let's assume that this is a local network that does not have access to internet.

"aleksz-wifi" - wireless connection. Has access to internet resources, like Skype.

How does Ubuntu know which one of those connections should be used to access public web? Simple, there is a routing table. You can see it with "route" command.



The Routing Table


That's what I get. I did not configure anything yet. You can assume this routing table to be more or less random.

Probably, you would not be reading this post if you would understand how routing table works, so I will try to explain it a bit. In last column ("Iface"), you see interface name. eth0 is for "Wired connection 1" network and wlan0 is for "aleksz-wifi". First column ("Destination") together with third column ("Genmask") form the range of IP addresses for which this interface should be used. That's actually what we need. By changing routing table, we can say that one range of IP addresses should use one interface, and another range should use the other interface.

In given scenario, we need two ranges. On screenshot, you might have noticed that there is a "default" destination. This means, that we actually have to define rule for one range and all other addresses will be using "default" rule.

Default interface

Now you should think what interface will be "default". In given scenario, there are two facts that make us choose wlan0 as a default interface:

  1. We are going to use Skype on that interface. As Skype uses P2P network, it will be quite hard to identify destination IP range.
  2. If routing table hits some unknown IP, then most probably it will be an external resource.
If you pay attention, then you will notice that routing table on screenshot puts eth0 as default interface.

Changing configuration

There are many ways to  configure routing table, but we are going to use the easiest one.

Open "Edit Connections..." dialog


Open "Wired" tab and click "Add" button. We are going to create a new configuration that can be enabled manually 
Enter some "Connection name" and choose "Device MAC address" . Dropdown should contain MAC for eth0 interface. Uncheck "Connect automatically" check box if this is not your primary setting for wired connections.
Next go to "IPv4 Settings" tab (or v6, depending on your network). Click "Routes..." button.

In case if you are going to use this connection to access only resources available on local subnet - check "Use this connection only for resources on its network". Save your new configuration.

Now you can choose "my intranet" for wired connection
Let's check the routing table:


Here you go, default interface is wlan0. eth0 is still used for local connections.

That was easy. However, in real world it is highly possible that your local network structure will not be as plain as in my example. You might need access to resources on other subnets. This requires a bit more complex routing configuration:


Except for local subnet addresses, this configuration resolves addresses in other subnets through gateway.


35 comments:

  1. Problem: HP Printer not connecting to my laptop.

    I had an issue while connecting my 2 year old HP printer to my brother's laptop that I had borrowed for starting my own business. I used a quick google search to fix the problem but that did not help me.
    I then decided to get professional help to solve my problem. After having received many quotations from various companies, i decided to go ahead with Online Tech Repair (www.onlinetechrepairs.com).
    Reasons I chose them over the others:
    1) They were extremely friendly and patient with me during my initial discussions and responded promptly to my request.
    2) Their prices were extremely reasonable.
    3) They were ready and willing to walk me through the entire process step by step and were on call with me till i got it fixed.
    How did they do it
    1) They first asked me to state my problem clearly and asked me a few questions. This was done to detect any physical connectivity issues with the printer.
    2) After having answered this, they confirmed that the printer and the laptop were functioning correctly.
    3) They then, asked me if they could access my laptop remotely to troubleshoot the problem and fix it. I agreed.
    4) One of the tech support executives accessed my laptop and started troubleshooting.
    5) I sat back and watched as the tech support executive was navigating my laptop to spot the issue. The issue was fixed.
    6) I was told that it was due to an older version of the driver that had been installed.

    My Experience
    I loved the entire friendly conversation that took place with them. They understood my needs clearly and acted upon the solution immediately. Being a technical noob, i sometimes find it difficult to communicate with tech support teams. It was a very different experience with the guys at Online Tech Repairs. You can check out their website www.onlinetechrepairs.com or call them on 1-914-613-3786.
    Would definitely recommend this service to anyone who needs help fixing their computers.
    Thanks a ton guys. Great Job....!!

    ReplyDelete
  2. 1 Problem: HP Printer not connecting to my laptop.

    I had an issue while connecting my 2 year old HP printer to my brother's laptop that I had borrowed for starting my own business. I used a quick google search to fix the problem but that did not help me.
    I then decided to get professional help to solve my problem. After having received many quotations from various companies, i decided to go ahead with Online Tech Repair (www.onlinetechrepairs.com).
    Reasons I chose them over the others:
    1) They were extremely friendly and patient with me during my initial discussions and responded promptly to my request.
    2) Their prices were extremely reasonable.
    3) They were ready and willing to walk me through the entire process step by step and were on call with me till i got it fixed.
    How did they do it
    1) They first asked me to state my problem clearly and asked me a few questions. This was done to detect any physical connectivity issues with the printer.
    2) After having answered this, they confirmed that the printer and the laptop were functioning correctly.
    3) They then, asked me if they could access my laptop remotely to troubleshoot the problem and fix it. I agreed.
    4) One of the tech support executives accessed my laptop and started troubleshooting.
    5) I sat back and watched as the tech support executive was navigating my laptop to spot the issue. The issue was fixed.
    6) I was told that it was due to an older version of the driver that had been installed.

    My Experience
    I loved the entire friendly conversation that took place with them. They understood my needs clearly and acted upon the solution immediately. Being a technical noob, i sometimes find it difficult to communicate with tech support teams. It was a very different experience with the guys at Online Tech Repairs. You can check out their website www.onlinetechrepairs.com or call them on 1-914-613-3786.
    Would definitely recommend this service to anyone who needs help fixing their computers.
    Thanks a ton guys. Great Job....!!


    ReplyDelete
  3. Awesome Site!!!!!!!!!!! unique info and content !!!!!!!!!!! i like it !!!!!!!!!! Thanks for share!!!!! keep it up!!!!!!! visit more info!!!!! Skype Support !!!! and Call +1-800-231-4635 USA (Toll Free)!!!!!!!!

    ReplyDelete
  4. Excellent Instructions! Also understandable by people who aren't as familiar with networking issues. One of the few usable tutorials about this topic on t he net among a plenty of others which aren't very helpful. Thanks a lot and go on with the good work!

    ReplyDelete
  5. That is EXACTLY what I needed to know! Thanks for the great post!

    ReplyDelete
  6. This is apparently an important and helpful post. Thanks for sharing this post.

    CISCO Brand Fabric Extenders

    ReplyDelete
  7. Thank you. Your post resolve my problem in configuring both wired and wireless connections in ubuntu.

    ReplyDelete
  8. This is an incredible rousing article.I am essentially satisfied with your great work.You put truly supportive data. Keep it up. nimble mobile

    ReplyDelete
  9. For a typical home network, this isn’t a really big deal — your Internet connection is the bottleneck. But there is a difference between these cables, and you can get faster local network speeds by upgrading.Did you recently pick up a new Lan Network Cable, or did you use an Ethernet cable that came bundled with a modern router or other piece of equipment? It’s probably recent enough that you don’t need to worry.

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. I have never found a blog which shares general programming ideas in the past. Therefore, this blog encourages me to develop my programming skills across all scopes.I am learning that programming has given many the opportunity to be innovative and even develop sites which offer Nursing course admission Essay service.

    ReplyDelete
  12. Thanks for the great post. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

    Ethernet Network Cables

    ReplyDelete
  13. Can you share the same for Windows operating system....
    Best of Luck from Winsant

    ReplyDelete
  14. It was really nice to read article written on this blog. I would also like to add few techniques with best of my knowledge which can help reader more and more.
    RS485 Cable

    ReplyDelete
  15. Hello people! Do you have any site that will help me to improve my internet fast or increase its speed?

    ReplyDelete
  16. Thank you for taking the time to publish this information very useful!
    Network Cables

    ReplyDelete
  17. Thanks for sharing this information. I really like your blog post very much. You have really shared an informative and interesting blog post. Ethernet cords

    ReplyDelete
  18. Nice blog provides many informative and helpful articles. Thanks for sharing the information. Looking for more updates in future.
    Smart WI-FI In-Line Switch

    ReplyDelete
  19. Awesome post. Good Post. I like your blog. You Post is very informative. Thanks for Sharing.
    Download Speed Test

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. Thanks for the blog post, It helps me a lot salesforce customer portal

    ReplyDelete
  22. Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog. best router for multiple devices

    ReplyDelete
  23. This is great blog post i have read your others blog too. you can read my blog Spotify Error Code 3

    ReplyDelete
  24. Toughest topic you have solved and explained in easy way. Thanks for sharing.
    wifi and network security - Oceanaparttechnologies

    ReplyDelete
  25. Thank you very much admin,for share this nice blog.
    metallomontazh

    ReplyDelete
  26. Your blog is awesome. Thanks for providing this information. If you having any issues related to Yahoo Mail Issues, Call our 24*7 Email Helpline Number USA: +1 855-869-7373 UK: +44 800-041-8324.

    ReplyDelete
  27. Media cables are the most significant networking hardware used for linking a computer system into other computer systems or to connect a couple of machines to share printers, monitors etc. - Cat6a Plenum

    ReplyDelete
  28. This comment has been removed by the author.

    ReplyDelete
  29. If there is a connection error or there are other technical issues in the operating system and then you might be unable to download the AOL Desktop Gold. This is a very common issue and it can easily be sorted out with the right guidance.

    AOL Gold Automatic Update Error

    ReplyDelete
  30. If you don’t have a network to connect your computers then, the computer network cabling Gauteng services is best for your business. It's provide best offer with reasonable price.

    ReplyDelete
  31. This comment has been removed by the author.

    ReplyDelete