当前位置: 技术问答>linux和unix
debian系统修改ip,但是仍然无法连接外网 请高手指教
来源: 互联网 发布时间:2016-11-27
本文导语: 环境:debian系统 命令行模式 修改 vim /etc/network/interfaces :(修改ip) # The loopback network interface auto lo iface lo inet loopback # The primary network interface #allow-hotplug eth0 auto eth0 iface eth0 inet static addre...
环境:debian系统 命令行模式
修改 vim /etc/network/interfaces :(修改ip)
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0
auto eth0
iface eth0 inet static
address 192.168.16.119
netmask 255.255.252.0
broadcast 192.168.16.255
network 192.168.16.0
# gateway 192.168.16.1
# dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 192.168.17.244
dns-nameservers 202.96.209.5
gateway 192.168.16.1
# dns-search unassigned-domain
iface eth1 inet static
address 192.168.19.72
netmask 255.255.252.0
重启network服务:/etc/init.d/networking restart
iFile:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:83:01:22
inet addr:192.168.16.119 Bcast:192.168.16.255 Mask:255.255.252.0
inet6 addr: fe80::250:56ff:fe83:122/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13002 errors:0 dropped:0 overruns:0 frame:0
TX packets:811 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1004514 (980.9 KiB) TX bytes:85698 (83.6 KiB)
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:16436 Metric:1
RX packets:4423 errors:0 dropped:0 overruns:0 frame:0
TX packets:4423 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1174134 (1.1 MiB) TX bytes:1174134 (1.1 MiB)
此时应该可以访问外网了(公司16网段可以访问外网)
但是不知为什么,就是无法连接外网 请高手指教,还有哪里需要修改
修改 vim /etc/network/interfaces :(修改ip)
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0
auto eth0
iface eth0 inet static
address 192.168.16.119
netmask 255.255.252.0
broadcast 192.168.16.255
network 192.168.16.0
# gateway 192.168.16.1
# dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 192.168.17.244
dns-nameservers 202.96.209.5
gateway 192.168.16.1
# dns-search unassigned-domain
iface eth1 inet static
address 192.168.19.72
netmask 255.255.252.0
重启network服务:/etc/init.d/networking restart
iFile:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:83:01:22
inet addr:192.168.16.119 Bcast:192.168.16.255 Mask:255.255.252.0
inet6 addr: fe80::250:56ff:fe83:122/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13002 errors:0 dropped:0 overruns:0 frame:0
TX packets:811 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1004514 (980.9 KiB) TX bytes:85698 (83.6 KiB)
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:16436 Metric:1
RX packets:4423 errors:0 dropped:0 overruns:0 frame:0
TX packets:4423 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1174134 (1.1 MiB) TX bytes:1174134 (1.1 MiB)
此时应该可以访问外网了(公司16网段可以访问外网)
但是不知为什么,就是无法连接外网 请高手指教,还有哪里需要修改
|
dns应该设置/etc/resolv.conf
nameserver 202.96.209.5
如果用楼主的设置方法要安装resolvconf的,最好先注释掉这句话dns-nameservers 202.96.209.5
至于网关不能ping通,有可能你的ip地址重了,导致收不到回包,你要用一个能上网的ip地址
先人工设置ip,ifconfig eth0 192.168.16.119
然后看看能不能通 ping 192.168.16.1
一直到能ping通了,然后再改配置文件让其永久生效
nameserver 202.96.209.5
如果用楼主的设置方法要安装resolvconf的,最好先注释掉这句话dns-nameservers 202.96.209.5
至于网关不能ping通,有可能你的ip地址重了,导致收不到回包,你要用一个能上网的ip地址
先人工设置ip,ifconfig eth0 192.168.16.119
然后看看能不能通 ping 192.168.16.1
一直到能ping通了,然后再改配置文件让其永久生效
|
ping的通dns否,netstat -r路由设置争取否
|
我在我的虚拟机上 按照lz的配置测试eth0没问题,你检查下 是不是dns 网关什么的问题