How to set up the gateway for wlan0?

UserK

I am using a private hotspot to connect a Raspberry Py to internet. I've setup the password and the ssid in the /etc/network/interfaces file. With this configuration I'm able to connect to the wifi but I can't connect to internet.

pi@tenzo /etc $ ping google.com
PING google.com (173.194.40.2) 56(84) bytes of data.
From tenzo.local (192.168.1.115) icmp_seq=1 Destination Host Unreachable

I've asked around and they said it's a gateway issue. Running traceroute from a laptop connected to the same network I get:

userk@dopamine:~$ traceroute google.com
traceroute to google.com (216.58.212.110), 30 hops max, 60 byte packets
 1  192.168.43.1 (192.168.43.1)  2.423 ms  5.088 ms  5.084 ms
 2  * * *
 3  10.4.129.165 (10.4.129.165)  120.018 ms  120.027 ms  120.020 ms
 4  10.4.129.196 (10.4.129.196)  129.488 ms  129.490 ms  129.471 ms
 5  10.4.129.196 (10.4.129.196)  138.994 ms  141.969 ms  144.439 ms

Do you have any advice?

EDIT 1 I've added to the interfaces the gateway, address and netmask. SEE EDIT 2

Now, when I ping google.com I get the same error as before...

This is the output of route -n

pi@tenzo ~ $ route -n
Kernel IP routing table
Destination     Gateway       Genmask      Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1   0.0.0.0       UG    0      0        0 eth0
0.0.0.0         192.168.43.1  0.0.0.0       UG    303    0        0 wlan0
192.168.1.0     0.0.0.0      255.255.255.0   U     0      0        0 eth0
192.168.43.0    0.0.0.0      255.255.255.0   U     303    0        0 wlan0

EDIT 2 This is my interfaces file:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static

address 192.168.1.115
netmask 255.255.255.0
gateway 192.168.1.1

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
        address 192.168.43.235
        netmask 255.255.255.0
        gateway 192.168.43.1
        wpa-ssid "UserKOnTheNet"
        wpa-psk "xxxxx"

This is the output of traceroute

pi@tenzo ~ $ traceroute google.com
traceroute to google.com (173.194.40.7), 30 hops max, 60 byte packets
 1  tenzo.local (192.168.1.115)  2995.172 ms !H  2995.058 ms !H  2995.016 ms !H
Wouter Verhelst

A gateway would need to be configured in your interfaces file; e.g., something like

iface wlan0 inet static
    address 192.168.x.y
    gateway 192.168.x.z
    netmask 255.255.255.0

would work (where x is your network number, y the address for your host, and z the address for your gateway). Obviously you need to retain your encryption settings, too.

If you're using dhcp on that interface, then something is wrong with your dhcp server.

EDIT: you should also make sure no other network interface has a gateway setting, or if it does, that the gateway setting on that interface is correct. A "gateway" or "default gateway" is a machine which offers a connection to the Internet. It is a valid configuration to have a network interface without a gateway line if no such host exists on that network connection.

In your case, assuming there is no internet router on the network that eth0 is linked to, you should ensure that the iface eth0 stanza looks like this:

iface eth0 inet static
    address 192.168.1.115
    netmask 255.255.255.0

i.e., what you already have, but without the gateway 192.168.1.1 line. (the indentation at the start of the line is optional, but does make the file easier to read).

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

"Could not set interface wlan0 flags (UP): Input/output error" RT3290

분류에서Dev

리눅스 c / c ++ : ifconfig wlan0 up output 얻기

분류에서Dev

How to set up maven?

분류에서Dev

wlan0 is missing?

분류에서Dev

How to set up USB for Virtualbox?

분류에서Dev

IPv6 : ADDRCONF (NETDEV_UP) : wlan0 : 링크가 준비되지 않았습니다.

분류에서Dev

No DHCP lease with wlan0

분류에서Dev

Disabling wlan0 adapter

분류에서Dev

How to set DHCP interface as default gateway in Debian 9

분류에서Dev

How do I set up a server for SSH?

분류에서Dev

How to set up git for wordpress theme development

분류에서Dev

How to set up image DIV for overlay animation

분류에서Dev

Flycheck and Clutter - how can I set it up?

분류에서Dev

How to set up a clear SuSE-Firewall?

분류에서Dev

How do I set up an email server?

분류에서Dev

How to set up an array with related items

분류에서Dev

How to set up webcam for skype conversation?

분류에서Dev

The n mode on "iwlist wlan0 scan"

분류에서Dev

Conflict in wlan0 management on ArchLinux

분류에서Dev

I haven't got wlan0

분류에서Dev

"인터페이스 wlan0 플래그를 설정할 수 없습니다 (UP) : 입력 / 출력 오류"RT3290

분류에서Dev

How to properly set up 2 network interfaces in CentOS (running in VirtualBox)?

분류에서Dev

How to set up DBus query to get play state of VLC?

분류에서Dev

How can I set up logging for node-mongod-native?

분류에서Dev

How to set up custom routing for wildcard subdomains in Nancyfx

분류에서Dev

How to set up development environment for a particular version of ios

분류에서Dev

How can I set up Git branch for automatic backups

분류에서Dev

How to set up Node.JS with Express and Socket.IO?

분류에서Dev

How can I set up conditional associations in Rails?

Related 관련 기사

뜨겁다태그

보관