ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux---ubutun internet connection set

linux---ubutun internet connection set

原创 Linux操作系统 作者:lily_durham 时间:2010-03-10 04:37:38 0 删除 编辑
Change Ubuntu Server from DHCP to a Static IP Address (OR SETUP NETWORK CONNECTION):
sudo vi /etc/network/interfaces

For the primary interface, which is usually eth0, you will see these lines:
auto eth0
iface eth0 inet dhcp

If you see the above two lines then it's using DHCP.
To change dhcp to static.

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1

Now we'll need to add in the DNS settings by editing the resolv.conf file:

sudo vi /etc/resolv.conf
‘name server xxx.xxx.xxx.xxx’ replace the x with the IP of your name server. (You can do ifconfig /all to find out what they are)

You need to also remove the dhcp client for this to stick (thanks to Peter for noticing). You might need to remove dhcp-client3 instead.

sudo apt-get remove dhcp-client

Now we'll just need to restart the networking components:

sudo /etc/init.d/networking restart

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15734550/viewspace-629061/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: linux命令学习1
请登录后发表评论 登录
全部评论

注册时间:2009-08-04

  • 博文量
    28
  • 访问量
    45203