我在配置 ubuntu 13.04 以拥有静态 IP 地址时遇到了很大困难。我尝试了多种解决方案,但每次我重新启动时(无法执行网络重置命令,因为 ubuntu 会冻结)我都无法连接。
这是我在终端中输入 ifconfig 时得到的结果:
eth0 Link encap:Ethernet HWaddr 10:bf:48:bc:07:cb
inet addr:192.168.0.8 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::12bf:48ff:febc:7cb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1763067 errors:0 dropped:0 overruns:0 frame:0
TX packets:1024326 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2284491220 (2.2 GB) TX bytes:136809317 (136.8 MB)
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:1840 errors:0 dropped:0 overruns:0 frame:0
TX packets:1840 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:185688 (185.6 KB) TX bytes:185688 (185.6 KB)
我也尝试过这个:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.160
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 24.222.0.94
dns-nameservers 24.222.0.95
如果有人能帮助我,我将非常感激。
答案1
请按照以下步骤将系统的 IP 地址变为静态:
- 打开接口文件(
sudo vi /etc/network/interfaces
) 寻找
auto eth0 iface eth0 inet dhcp
用以下命令替换上述命令
auto eth0 iface eth0 inet static address 192.168.1.100(Enter desired ip here) netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1
然后输入
sudo ifdown eth0; sudo ifup eth0
答案2
这对我有用。
auto eth0
iface eth0 inet static
address 192.168.0.160
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 24.222.0.94 24.222.0.95