编辑:
sudo ifdown wlx000e0008833e && sudo ifup -v wlx000e0008833e
:
Configuring interface wlx000e0008833e=wlx000e0008833e (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/ethtool
run-parts: executing /etc/network/if-pre-up.d/ifenslave
+ [ inet = meta ]
+ IF_BOND_SLAVES=
+ [ ]
+ [ ]
+ [ -z ]
+ exit
run-parts: executing /etc/network/if-pre-up.d/vlan
/bin/ip addr add 192.168.0.50/255.255.255.0 broadcast 192.168.0.255 dev wlx000e0008833e label wlx000e0008833e
/bin/ip link set dev wlx000e0008833e up
/bin/ip route add default via 192.168.0.1 dev wlx000e0008833e onlink
/bin/run-parts --exit-on-error --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/000resolvconf
run-parts: executing /etc/network/if-up.d/ethtool
run-parts: executing /etc/network/if-up.d/ifenslave
+ [ inet = meta ]
+ [ ]
run-parts: executing /etc/network/if-up.d/ip
run-parts: executing /etc/network/if-up.d/openssh-server
run-parts: executing /etc/network/if-up.d/upstart
dmesg | grep wlx
:
[ 16.181623] mt7601u 1-6:1.0 wlx000e0008833e: renamed from wlan0
[ 16.309273] IPv6: ADDRCONF(NETDEV_UP): wlx000e0008833e: link is not ready
[ 187.708914] IPv6: ADDRCONF(NETDEV_UP): wlx000e0008833e: link is not ready
[ 1333.308500] mt7601u 1-6:1.0 wlx000e0008833e: renamed from wlan0
[ 1333.502331] IPv6: ADDRCONF(NETDEV_UP): wlx000e0008833e: link is not ready
[ 1357.986859] IPv6: ADDRCONF(NETDEV_UP): wlx000e0008833e: link is not ready
情况:
我有一台装有 Ubuntu Server 16.04 操作系统的服务器。我需要使用 USB wifi 适配器将其连接到 wifi 网络,但在调试时遇到了一些问题。
当我插入 USB wifi 适配器并运行时,ifconfig -a
我可以看到此信息(之前我做的设置):
wlx000e0008833e Link encap:Ethernet HWaddr 00:0e:00:08:83:3e
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
无线网络配置:
network name (ssid):
开发者调制解调器password:
cHc0h6qZ3Hv8wscFsecurity:
WPA/WPA2IPv4 address:
192.168.0.109
当我连接到我的 PC 时有关同一网络的信息 ( Ubuntu Desktop 16.04 AMD64
):
有关我的调制解调器的信息:
我做的设置:
我将此脚本添加到/etc/networks/interfaces
:
# The wifi network interface
auto wlx000e0008833e
iface wlx000e0008833e inet static
address 192.168.0.109
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
dns-nameservers 192.168.0.1 8.8.8.8
wpa-ssid developer-modem
wpa-psk cHc0h6qZ3Hv8wscF
问题:
当我 ping 192.168.0.109
(我的调制解调器) 时,我得到了响应:
PING 192.168.0.109 (192.168.0.109) 56(84) bytes of data:
64 bytes from 192.168.0.109: icmp_seq=1 ttl=64 time=0.044 ms
64 bytes from 192.168.0.109: icmp_seq=2 ttl=64 time=0.047 ms
...
64 bytes from 192.168.0.109: icmp_seq=5 ttl=64 time=0.044 ms
--- 192.168.0.109 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3997 ms
当我 ping 192.168.0.1
(第一个 dns-nameserver) 时,收到错误响应:
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data:
From 192.168.0.109 icmp_seq=1 Destination Host Unreachable
From 192.168.0.109 icmp_seq=2 Destination Host Unreachable
...
From 192.168.0.109 icmp_seq=5 Destination Host Unreachable
--- 192.168.0.1 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3017 ms
当我 ping 8.8.8.8
(第二个 dns-nameserver) 时收到错误:
connect: Network is unreachable
当我 ping 任何其他地址(例如www.google.com
)时,我收到错误:
ping: unknown host www.google.com
问题:
我不确定一切都设置好了,因为我只是做了更改/etc/network/interfaces
(参见上面的更改),没有做其他更改。
如何解决这个问题?
感谢帮助
答案1
我建议您将服务器上的接口文件更改为:
auto lo
iface lo inet loopback
# The wifi network interface
auto wlx000e0008833e
iface wlx000e0008833e inet static
address 192.168.0.50
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1 8.8.8.8
wpa-ssid developer-modem
wpa-psk cHc0h6qZ3Hv8wscF
重启。
服务器是否已连接?检查:
ping -c3 192.168.0.1
ping -c3 www.ubuntu.com