ubuntu 網路問題

2021-07-05 04:39:49 字數 3982 閱讀 2936

配置:vi  /etc/network/inte***ces    #可設定dhcp或靜態ip

設定動態新增,

auto eth0

iface eth0 inet dhcp

安裝dhcp3 server

apt-get install isc-dhcp-server   (或sudo apt-get install dhcp3-server)

編輯檔案/etc/default/isc-dhcp-server  (或vi /etc/default/dhcp3-server)  #預設監聽eth0

填入eth0

inte***ces="eth0"

cp /etc/dhcp/dhcpd.conf  /etc/dhcp/dhcpd.conf.bak      #備份

編輯檔案:/etc/dhcp/dhcpd.conf

default-lease-time 600;        #ip預設租期

max-lease-time 7200;         #ip最長租期

option subnet-mask 255.255.255.0;     #子網掩碼

option broadcast-address 192.168.1.255;

option routers 192.168.1.254;       #閘道器位址

option domain-name-servers 192.168.1.1, 192.168.1.2;

option domain-name 「yourdomainname.com」;

subnet 192.168.1.0 netmask 255.255.255.0

包括router位址, ip位址範圍,dns server ip, 廣播ip位址等。

/etc/init.d/dhcpd start      

服務命令: service isc-dhcp-server start

注意,dhcp使用的位址必須是和eth0在乙個網段。

host server1

host printer1

lamp dhcp設定(備查)

vi /etc/dhcp/dhcpd.conf

option domain-name-servers 8.8.8.8, 202.96.209.133;

subnet 192.168.44.0 netmask 255.255.255.0

設定靜態新增,

# the loopback network inte***ce

auto lo

iface lo inet loopback

# the primary network inte***ce

auto eth0               #讓網絡卡開機自動掛載

iface eth0 inet static

address 10.31.44.211

netmask 255.255.255.0

gateway 10.31.44.1

#network 10.31.44.0

#broadcast 10.31.44.255

# dns-* options are implemented by the resolvconf package, if installed

dns-nameservers 202.96.209.133

根據情況填寫address、netmask、gateway、network、broadcast 等資訊。

vi  /etc/resolv.conf

新增,nameserver 202.96.209.133

重啟網路: /etc/init.d/networking restart

設定主機名: sudo vi /bin/hostname

客戶端:

vi  /etc/network/inte***ces

auto lo eth0

iface eth0 inet dhcp

iface lo inet loopback

/etc/init.d/networking restart

dns:

在 /etc/hosts 中加入主機名和這些主機名對應的ip位址

要訪問dns 伺服器,需要設定 /etc/resolv.conf 檔案,新增: nameserver 114.114.114.114

sudo /etc/init.d/networking restart

sudo /etc/init.d/dhcp3-server restart

命令:ifconfig

ifconfig -a    列出所有網絡卡資訊

停用網路介面卡   ifconfig eth1 down

啟用網路介面卡   ifconfig eth1 up

為網路介面卡eth0設定ip位址    ifconfig eth0 192.168.1.12      此配置立即生效,但重啟網路服務和系統會失效。

更改網路介面卡eth0的子網掩碼     ifconfig eth0 netmask 255.255.255.0

更改網路介面卡eth0的廣播位址     ifconfig eth0 broadcast 192.168.1.255

為eth0指定ip位址,子網掩碼,廣播位址     ifconfig eth0 192.168.1.12  netmask 255.255.255.0  broadcast 192.168.1.255

新增預設閘道器:

route add default gw 192.168.1.1

question:

網絡卡無法正常啟動:

刪除配置規則後重啟 rm -rf  /etc/udev/rules.d/70-persistent-net.rules

雙網絡卡問題:

eth0設定內網ip, eth1設定為外網ip,內網不用設定閘道器,(內網ip為192.168.1.211,內網閘道器為192.168.1.1,外網ip為210.28.11.4)

由於沒有設定內網閘道器,所以我們用 securecrt 之類的工具連不上伺服器.為了解決這個問題,我們需要設定伺服器的路由.如下:

sudo route add -net 192.168.2.0/24 gw 192.168.1.1 dev eth0

sudo route add -net 192.168.20.0/24 gw 192.168.1.1 dev eth0

sudo route add -net 192.168.30.0/24 gw 192.168.1.1 dev eth0

以上命令依次分別為 192.168.2.x,192.168.20.x,192.168.30.x 三個網段設定路由。

如果連不上外網,嘗試命令 : sudo route add default gw 222.76.250.4 dev eth1

以上資訊重啟會丟失,所以通過執行一段指令碼來新增路由:

建立乙個 /etc/network.script 檔案,把以上內容編輯進去,後編輯 /etc/rc.local

dhcp配置例項:

156-dhcpd.conf

option domain-name "nitcloud.org";

default-lease-time 600;

max-lease-time 7200;

log-facility local7;

subnet 10.31.44.0 netmask 255.255.255.0

156-/etc/default/isc-dhcp-server 

options="-p 78"

inte***ces="br0"

159-dhcpd.conf

default-lease-time 600;

max-lease-time 7200;

log-facility local7;

subnet 10.31.44.0 netmask 255.255.255.0

159-/etc/default/isc-dhcp-server 

inte***ces=""

Vmware下ubuntu網路問題

出現的問題大概是無法聯網,顯示裝置未託管。各種找,各種橋接,發現都是解決不了問題。最後找到一篇部落格,大致意思是ubuntu有兩套管理網路的方案 1 etc network inte ces 2 network manager 此時我配置inte ces檔案配到想吐,於是決定換個管理方式 配置了1 ...

ubuntu網路配置問題總結1

網絡卡重啟 service etc init.d networking restart 已經廢棄 service network restart service為redhat系列的專用啟動方式在ubuntu中使用不了 可以使用ifup ifconfig eth0 啟動eth0 ifdown ifco...

ubuntu 9 04 有線網路問題

安裝完成之後一直用無線網路,相當完美。但是假期跑去海南,在酒店的時候,只能使用有線網路,插上網線,發現沒有任何反應,包括網線燈都沒有閃爍,換了幾個網線都這樣,一定是硬體驅動問題了。查了系統的network connections,查了ifconfig,似乎沒有網絡卡驅動。因為天已經太晚,而且也沒有其...