我在 MacBook Pro 上运行 Ubuntu 16.04 LTS。删除网络管理器并安装 dnsmasq 后,我失去了互联网连接。我通过无线接口 (wlan0) 连接到互联网,并想通过以太网 (eth0) 接口设置 DHCP 和 DNS 服务。
如果我在接口文件上定义 wlan0,则不会从无线路由器为该接口分配 IP 地址,但是,如果接口不是定义后,接口获得了有效的IP地址,但没有DNS服务。
# cat /etc/network/interfaces
auto lo
iface lo inet loopback
#If the interface is defined here, I don"t get an IP address from DHCP (why?!)
#auto wlan0
#iface wlan0 inet dhcp
auto eth0
iface eth0 inet static
address 192.168.10.1
netmask 255.255.255.0
# cat /etc/dnsmasq.conf
domain-needed
listen-address=127.0.0.1
filterwin2k
local=/oeinc.lan/
interface=eth0
bind-interfaces
expand-hosts
domain=oeinc.lan
dhcp-range=192.168.10.50,192.168.2.150
# iwconfig
wlan0 IEEE 802.11abg **ESSID:"Macondo"**
Mode:Managed Frequency:5.765 GHz Access Point: A0:63:91:D6:88:17
Bit Rate=450 Mb/s Tx-Power=200 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
Link Quality=68/70 Signal level=-42 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
# ifconfig
eth0 Link encap:Ethernet HWaddr 0c:4d:e9:b3:ac:01
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
UP 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)
Interrupt:16
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:16112 errors:0 dropped:0 overruns:0 frame:0
TX packets:16112 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:969596 (969.5 KB) TX bytes:969596 (969.5 KB)
wlan0 Link encap:Ethernet HWaddr 2c:be:08:e9:30:a2
inet **addr:192.168.1.5** Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::71a9:2169:3f1:4be8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1394 errors:0 dropped:0 overruns:0 frame:78
TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:142914 (142.9 KB) TX bytes:27624 (27.6 KB)
Interrupt:17
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 600 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 eth0
192.168.1.0 * 255.255.255.0 U 600 0 0 wlan0
192.168.10.0 * 255.255.255.0 U 0 0 0 eth0
# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=4.88 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=3.53 ms
# nslookup google.com
Server: 127.0.0.1
Address: 127.0.0.1#53
** server can't find google.com: REFUSED