注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

notes

@-@

 
 
 

日志

 
 
 
 

Ubuntu network  

2009-07-21 15:30:04|  分类: UNIX |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
Ubuntu的网络参数保存在文件 /etc/network/interfaces中,默认设置使用dhcp,内容如下:

# The primary network interface
auto eth0
iface eth0 inet dhcp

设置静态ip的方法如下:
1) 编辑 /etc/network/interfaces
1.1)将dhcp 一行屏蔽
# The primary network interface
auto eth0
#iface eth0 inet dhcp

1.2)添加和静态ip有关的参数
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1

2)编辑 /etc/resolv.conf,设置dns
nameserver 202.96.134.133
nameserver 202.106.0.20

3)执行下面两个命令,启用新设置
$sudo ifdown eth0
$sudo ifup eth0


在gnome下修改网络配置, 使用的是gnome-network-admin这个包,

但是执行[系统]-[系统管理]-[网络],输入root口令后,出现错误提示:
"系统管理员不允许您访问系统配置。"

从po中找到英文原文是

"You are not allowed to access the system configuration." 

然后到google查找["You are not allowed to access the system configuration." gnome]

找到2个建议

1.需要把用户 加进admin用户组

  groupadd admin

  addgroup loongson admin

2.重装dbus

 aptitude reinstall dbus

反正2步都执行后,问题解决了。不管是谁起作用了吧。



ubuntu系统在安装时如果没有配置IP你只要开启SSH后配置一个IP及网关就可以远程操作了。下面就如何设置IP作个介绍:

一、ifconfig  eth0(网卡名称) 10.0.0.5(ip地址) netmask 255.255.255.0(掩码)

二、route add default gw 10.0.0.1(网关)

三、开启SSH
查看是否有/etc/ssh/sshd_config文件
1、cat /etc/ssh/sshd_config
如果有则:
2、/etc/init.d/ssh  restart
没有这个文件则:
3、apt-get update(升级)
4、apt-get  install  ssh
5、y

四、系统安装时没有root用户的处理:
1、sudo  passwd后输入三次密码(已有的非root用户的)
2、userdel  -f 12345(密码) 两次
3、这时退出以root的用户登录。



# 修改ip地址
即时生效:
# ifconfig eth0 192.168.0.20 netmask 255.255.255.0
启动生效:
修改/etc/sysconfig/network-scripts/ifcfg-eth0

# 修改default gateway
即时生效:
# route add default gw 192.168.0.254
启动生效:
修改/etc/sysconfig/network-scripts/ifcfg-eth0

# 修改dns
修改/etc/resolv.conf
修改后可即时生效,启动同样有效

# 修改host name
即时生效:
# hostname fc2
启动生效:
修改/etc/sysconfig/network

Your main network configuration file is /etc/network/interfaces

Desired new sample settings:
=> Host IP address 192.168.1.100
=> Netmask: 255.255.255.0
=> Network ID: 192.168.1.0
=> Broadcast IP: 192.168.1.255
=> Gateway/Router IP: 192.168.1.254
=> DNS Server: 192.168.1.254
Open network configuration file
de style="color: rgb(255, 0, 0);"<$ sudo vi /etc/network/interfacesde<
ORde<
de<
de<$ sudo nano /etc/network/interfacesde<
Find and remove dhcp entry:
de<iface eth0 inet dhcpde<
Append new network settings:
de<iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
de<
Save and close the file. Restart the network:
de<$ sudo /etc/init.d/networking restartde<

Task: Define new DNS servers

Open /etc/resolv.conf file
de<$ sudo vi /etc/resolv.conf de<
You need to remove old DNS server assigned by DHCP server:
de<search myisp.com
nameserver 192.168.1.254
nameserver 202.54.1.20
nameserver 202.54.1.30
de<
Save and close the file.

Task: Test DNS server

de<$ host cyberciti.bizde<

Network command line cheat sheet

You can also use commands to change settings. Please note that these settings are temporary and not the permanent. Use above method to make network changes permanent or GUI tool as described below.

Task: Display network interface information

de<$ ifconfigde<

Task: Take down network interface eth0 / take a network interface down

de<$ sudo ifconfig eth0 downde<OR de<$ sudo ifdown eth0 de<

Task: Bring a network interface eth0 up

de<$ sudo ifconfig eth0 upde<ORde<$ sudo ifup eth0 de<

Task: Change IP address and netmask from command line

Activate network interface eth0 with a new IP (192.168.1.50) / netmask:
de<$ sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 upde<

Task: Display the routing table

de<$ /sbin/route de<ORde<$ /sbin/route -nde<
Output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
localnet * 255.255.255.0 U 0 0 0 ra0
172.16.114.0 * 255.255.255.0 U 0 0 0 eth0
172.16.236.0 * 255.255.255.0 U 0 0 0 eth1
default 192.168.1.254 0.0.0.0 UG 0 0 0 ra0

Task: Add a new gateway

de<$ sudo route add default gw 172.16.236.0de<

Task: Display current active Internet connections (servers and established connection)

de<$ netstat -natde<

Task: Display open ports

de<$ sudo netstat -tulpde<ORde<$ sudo netstat -tulpnde<

Task: Display network interfaces stats (RX/TX etc)

de<$ netstat -ide<

Task: Display output for active/established connections only

de<$ netstat -e
$ netstat -te
$ netstat -tue
de<
Where,
  • -t : TCP connections
  • -u : UDP connections
  • -e : Established

Task: Test network connectivity

Send ICMP ECHO_REQUEST to network hosts, routers, servers etc with ping command. This verifies connectivity exists between local host and remote network system:
de<$ ping router
$ ping 192.168.1.254
$ ping cyberciti.biz
de<

Task: Use GUI (Graphical Configuration) network Tool

If you are new, use GUI configuration tool, type the following command at terminal:
de<$ network-admin &de<
Above command is Ubuntu's GUI for configuring network connections tool.

Final tip - Learn how find out more information about commands

A man page is your best friend when you wanted to learn more about particular command or syntax. For example, read detailed information about ifconfig and netstat command:
de<$ man ifconfig
$ man netstat
de<
Just get a short help with all command options by appending --help option to each command:
de<$ netstat --helpde<
Find out what command is used for particular task by searching the short descriptions and manual page names for the keyword:
de<$ man -k 'delete directory'
$ apropos -s 1 remove
de<
Display short descriptions of a command:
de<$ whatis rm
$ whatis netstat
de<
Linux offers an excellent collection of utilities, which can be use to finding the files and executables, remember you cannot memorize all the commands and files ;)

  评论这张
 
阅读(4543)| 评论(6)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018