- Создание соединения между 2-мя linux компьютерами через Wi-Fi на примере Ubuntu
- 7 комментариев
- Добавить комментарий Отменить ответ
- How to get connection to both wifi as well as LAN in ubuntu 14.04 LTS?
- 2 Answers 2
- Can I use Wi-Fi and cable (Ethernet) networking at same time?
- 3 Answers 3
- Share wireless Internet connection through ethernet
- 2 Answers 2
- On the server computer:
- On the client computer:
Создание соединения между 2-мя linux компьютерами через Wi-Fi на примере Ubuntu
Бывают случаи когда необходимо соединить компьютеры или раздать через компьютер интернет для телефона через Wifi.
Допустим соединяем 2 ноутбука оснащенные wifi картами.
На первом компьютере выполняем:
ifconfig wlan0 down
iwconfig wlan0 channel 6
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid ‘wifi’
iwconfig wlan0 key your_pass
ifconfig wlan0 192.168.1.1
На втором делаем тоже самое только изменив IP адрес:
ifconfig wlan0 down
iwconfig wlan0 channel 6
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid ‘wifi’
iwconfig wlan0 key your_pass
ifconfig wlan0 192.168.1.2
Все сеть готова 🙂 можете обмениваться файлами, ширить интернет, играть и т.д.
Так же этот пример применим если необходимо подключить iPhone к интернету, выполняем на компьютере заменяя ethX, IP_YOUR_LAN_CARD номером сетевой карты и IP адресом сетевухи через которую идет подключение к инету :
ifconfig wlan0 down
iwconfig wlan0 channel 6
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid ‘wifi’
iwconfig wlan0 key your_pass
ifconfig wlan0 192.168.1.1
iptables -A POSTROUTING -t nat -s 192.168.1.2 -o ethX -j SNAT —to-source IP_YOUR_LAN_CARD
echo 1 > /proc/sys/net/ipv4/ip_forward
Ловим телефоном сеть, устанавлием IP 192.168.1.2 Шлюз 192.168.1.1 и ДНС выданный вам провайдером. Интернет должен работать 😉
7 комментариев
Vovanys, а можно ли подобным образом заставить WiFi чип (не ноутбука, а некоего другого устройства) убедить работать в качестве точки доступа?
От чего зависит такая возможность?
sudo apt-get install iw вообще не надо это отдельная утилита которой в описании ты походу ни разу не воспользовался
ifconfig wlan0 down
iwconfig wlan0 channel 6
Error for wireless request «Set Frequency» (8B04) :
SET failed on device wlan0 ; Network is down.
так и должно быть.
не должно..
под рутом пробуешь?
Network Manager попробуй приостановить sudo /etc/init.d/network-manager stop
под рутом
# ifconfig wlan0 down
# iwconfig wlan0 channel 6
Error for wireless request «Set Frequency» (8B04) :
SET failed on device wlan0 ; Network is down.
# iwlist scan
wwan0 Interface doesn’t support scanning.
ppp0 Interface doesn’t support scanning.
eth0 Interface doesn’t support scanning.
lo Interface doesn’t support scanning.
wlan0 Interface doesn’t support scanning : Network is down
# /etc/init.d/network-manager stop
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service network-manager stop Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop network-manager
network-manager stop/waiting
# ifconfig wlan0 down
# iwconfig wlan0 channel 6
Error for wireless request «Set Frequency» (8B04) :
SET failed on device wlan0 ; Network is down.
# /etc/init.d/network-manager start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service network-manager start Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start network-manager
network-manager start/running, process 6122
# ребут # modprobe ath9k чтобы беспроводная снова появилась в менежере соединений как то так … (
Добавить комментарий Отменить ответ
Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.
How to get connection to both wifi as well as LAN in ubuntu 14.04 LTS?
On my Ubuntu 14.04 LTS laptop, I have a LAN connection with a static IP address as well as a WiFi connection to the internet using DHCP. LAN connection goes to a switch and WiFi connection from a WiFi access point. I need to connect both WiFi and LAN at the same time because I need the LAN for internal connectivity and the WiFi for the Internet. At present, I have to switch off the LAN to connect to the WiFi and vice versa.
I need to connect to my intranet which does not have internet connection (ssh) where as wifi is reuired to connect to internet to resolve issues. How I do i do the routing?
2 Answers 2
Step by Step Procedure:
Ubuntu allows multiple connections by default, but sometimes, we need to specify which one to use. In your comments, you have mentioned that you use LAN for the Intranet and WiFi for the Internet.
So, firstly search for Network Connections in the unity dash. Then, under the Ethernet section, click ‘Add’ button.
Then, we need to create a new Ethernet connection which we are going to enable manually. Uncheck the option of connecting automatically since this is your Intranet connection.
Then go to the IPv4/IPv6 settings (depending on your network) and then click on the Routes button. Check the ‘Use this connection only for resources on its network’ option. Click Save.
Now you can use both the LAN and WiFi simultaneously.
Source
This answer is correct, although it needs clarification. The old (!) ethernet connection has to be set to «not connect automatically». And then a new one has to be added with «use this connection only for resources on its network».
As the answer suggests I have set the new «Intranet» connection to not automatically connect. To use my Laptop this way I can quickly select this new network. I can still use it normally in other networks. Very nice solution 🙂
I wonder how it can be resolved at text mode. That is, how to do it at configuration files and commands?
I ended up finding a solution, detailed here: https://askubuntu.com/a/652426/432882
My question was about setting up network cameras on a local «intranet» through a switch, so I think the solution might work for you as well:
- Launch Network Connections, e.g. by clicking on the network icon at the upper right and choosing «Edit Connections. «
- Select the «Wired connection #» corresponding to the Ethernet port that will be connected to the switch. Choose «Edit. «
- Under the IPv4 Settings tab, change the Method drop-down from «Automatic (DHCP)» to «Disabled»
- Choose «Save. » A duplicate connection may appear in the list; choose «Close» and re-open Network Connections, and the duplicate will be gone (the duplicate item is a bug)
- Choose «Add», select «Ethernet», and choose «Create. «
- Type any name, e.g. «Intranet switch»
- Under the IPv4 Settings tab, change the Method drop-down to «Manual»
- Choose «Add» next to Addresses, and set Address to some value, either 10.m.n.p (e.g. 10.0.0.9), 172.q.r.s, or 192.168.y.z depending on how your intranet is set up. The address is for the Ubuntu computer, so it should be different from the other addresses on the intranet. See https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces for details.
- Set Netmask to 255.255.255.0 and leave Gateway blank.
- Fill the DNS servers field* with some address, e.g. 10.0.0.10
- Choose «Save. » and «Close»
Plug the switch into the Ethernet port. The «Intranet switch» connection might connect automatically, or you may have to select it. You should now be connected to the intranet through the switch. Additionally, connecting to the wireless network allows access to the internet via typical URLs. I have not tested this with an intranet that uses URLs for navigation, so you may need to navigate by numerical addresses.
I came upon this solution after watching the following video: https://www.youtube.com/watch?v=yqJ9PXhqOAQ
Theoretically, everything can be undone relatively easily by deleting the «Intranet switch» connection and setting «Wired connection #» from «Disabled» back to «Automatic (DHCP)»
*Please feel free to improve this answer by elaborating on the address in the DNS servers field.
Can I use Wi-Fi and cable (Ethernet) networking at same time?
I am on an intranet that is not connected to the Internet and a Wi-Fi router with connection to the Internet. When I am connected to the wireless network, I can browse the Internet, but I cannot browse my LAN with my Ethernet cable connected. How can I browse the Internet via my Wi-Fi router and at the same time browse my local LAN web application via my connected Ethernet cable?
How do you access «LAN applications»? Could you give us an example of the web address you are using to access them? Could you confirm that when you say «it tries to connect to the internet» you mean that when you try to access a LAN application it somehow tries to look for this application on the internet? How did you configure the network on your computer (both wireless and ethernet)?
@Huygens I use the following address for my LAN web based apps: xxx.xxx.com/weberp. or 10.10.100.3/weberp. And it tries to go to the internet. Both connections are DHCP.
What is nslookup xxx.xxx.com returning for IP on the Wireless and what is it returning on the ethernet LAN? In addition, what is the subnet of your DHCP Wireless LAN and what is the sunet of your DHCP ethernet LAN? Finally, what is the routing table when you are connected to the ethernet LAN ( route -n )?
For what i understand, the wireless and wired are 2 different connections, there should be no problem for your system to resolve local names through your lan interface. Can you provide us some info on your ip addresses / subnet mask? Run the following command on your console and give us the results: ifconfig or ip add Post the results.
3 Answers 3
You sure can. You didn’t specify it, but I’m assuming you get the IP address automatically (via DHCP) both on wireless and wired connection.
Wired Ethernet is faster than wireless, so if there are two ways to get somewhere, wired will takes precedence over Wi-Fi by default. With that said, when you connect to both links, both DHCP servers by default will advertise themselves as the default gateway for all of the traffic.
So now your computer thinks it has two ways to connect to the Internet, and since wired is preferred it’ll send traffic for the Internet via Ethernet. If that’s the case, you would see two gateways for default networks 0.0.0.0 in your routing table, route -n , one with your wireless router as a gateway and one for the wired.
But the Metric for the Ethernet gateway would be lower than wireless, so your PC will send the packets there. Now that your Ethernet router gets them, it doesn’t know what to do with them, so it just drops them. The order where you connected first shouldn’t matter.
As far as fixing (this assumes the DHCP case), the correct way would be to tell the LAN router to stop advertising itself as the default gateway. You need to log in to the router and look through settings. If you have no control over the router, you can remove it from your end with:
route del default gw eth.router.ip.address
Share wireless Internet connection through ethernet
I want to share the wireless Internet connection on my desktop with my old laptop, through ethernet. I have ticked the option «Make available to others» on both connections, on my desktop, but my laptop doesn’t connect. Am I doing something wrong or is it a bug?
I have done the exact same thing on 12.04 before. I am thinking there is a problem with network manager since i have Gnome 3.10 and it got updated today.
@Rmano: According to that article, modern Ethernet hardware auto-negotiates so crossover cables are not needed. I’ve also done this before with ordinary Ethernet cables.
@Mechanical snail: thanks, I didn’t noticed that. So I suppose I can dispose my precious manually connected cross-over cable 🙂
2 Answers 2
On the server computer:
- On the computer, which is connected to the Internet, click the network icon in the panel and go to «Edit Connections. « at the bottom of the menu.
- Double click your Wired Connection (Leave your wireless connection untouched, the one connected to Internet and the one you want to share, as I understand).
- On the «IPv4 Settings tab», select Method: «Shared to other computers»
- Reconnect by clicking on the Wired Network, so it gets a new IP address. (The two computers must be connected by an ethernet cable for this step, so connect them now if you haven’t already.)
- Click on «Connection Information» in the network menu and write down the IP address and network mask (in my case it was assigned 10.42.0.1/255.255.255.0 but I do not know if that will always be the case).
On the client computer:
- Go to «Edit Connections. » and assign a «Manual» Method. Assign an IP address on the same subnetwork (10.42.0.69 for example) and put the IP and network mask you wrote down in «Netmask» «Gateway» and «DNS servers»
- Reconnect to the network to let the new settings be assigned.
- Pat yourself on your back and surf away.