Ubuntu network
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步都执行后,问题解决了。不管是谁起作用了吧。
参考:
http://wiki.ubuntu.org.cn/UbuntuHelp:NetworkAdmin
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
国外文章:
http://www.ubuntugeek.com/ubuntu-networking-configuration-using-command-line.html
Your main network configuration file is /etc/network/interfaces
=> 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
de style="color: rgb(255, 0, 0);"<$ sudo vi /etc/network/interfacesde<
de<
de<iface eth0 inet dhcpde<
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
de<$ sudo vi /etc/resolv.conf de<
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
Network command line cheat sheet
Task: Display network interface information
Task: Take down network interface eth0 / take a network interface down
Task: Bring a network interface eth0 up
Task: Change IP address and netmask from command line
de<$ sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 upde<
Task: Display the routing table
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
Task: Display current active Internet connections (servers and established connection)
Task: Display open ports
Task: Display network interfaces stats (RX/TX etc)
Task: Display output for active/established connections only
$ netstat -te
$ netstat -tue
de<
- -t : TCP connections
- -u : UDP connections
- -e : Established
Task: Test network connectivity
de<$ ping router
$ ping 192.168.1.254
$ ping cyberciti.bizde<
Task: Use GUI (Graphical Configuration) network Tool
de<$ network-admin &de<
Final tip - Learn how find out more information about commands
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<
de<$ man -k 'delete directory'
$ apropos -s 1 removede<
de<$ whatis rm
$ whatis netstatde<