Ubuntu network

it2022-05-11  60

Ubuntu的网络参数保存在文件 /etc/network/interfaces中,默认设置使用dhcp,内容如下:# The primary network interfaceauto eth0iface eth0 inet dhcp设置静态ip的方法如下:1) 编辑 /etc/network/interfaces1.1)将dhcp 一行屏蔽# The primary network interfaceauto eth0#iface eth0 inet dhcp1.2)添加和静态ip有关的参数# The primary network interfaceiface eth0 inet staticaddress 192.168.0.10netmask 255.255.255.0gateway 192.168.0.12)编辑 /etc/resolv.conf,设置dnsnameserver 202.96.134.133nameserver 202.106.0.203)执行下面两个命令,启用新设置$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  ssh5、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

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 staticaddress 192.168.1.100netmask 255.255.255.0network 192.168.1.0broadcast 192.168.1.255gateway 192.168.1.254de<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.comnameserver 192.168.1.254nameserver 202.54.1.20nameserver 202.54.1.30de<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<OR de<$ /sbin/route -nde<Output: Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Ifacelocalnet * 255.255.255.0 U 0 0 0 ra0172.16.114.0 * 255.255.255.0 U 0 0 0 eth0172.16.236.0 * 255.255.255.0 U 0 0 0 eth1default 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 -tuede< 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.bizde< See simple Linux system monitoring with ping command and scripts for more information.

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 netstatde<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 removede< Display short descriptions of a command: de< $ whatis rm$ whatis netstatde< 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

转载于:https://www.cnblogs.com/stdanny/archive/2011/11/14/2248711.html

相关资源:ubuntu-network-manager-64位安装包

最新回复(0)