當前位置:首頁 » 幣種行情 » 如何刪掉eth0上的ip

如何刪掉eth0上的ip

發布時間: 2023-07-06 18:19:09

❶ 伺服器網卡操作

ip  [選項]  操作對象{link|addr|route...}

#  ip addr show                  # 顯示網卡IP信息

# ip addr add 192.168.0.1/24 dev eth0 # 設置eth0網卡IP地址192.168.0.1

# ip addr del 192.168.0.1/24 dev eth0 # 刪除eth0網卡IP地址

#  ip link show                             # 顯示網路介面信息

# ip link set eth0 up                  # 開啟網卡

# ip link set eth0 down             # 關閉網卡

# ip link set eth0 promisc on   # 開啟網卡的混合模式

# ip link set eth0 promisc offi  # 關閉網卡的混個模式

# ip link set eth0 txqueuelen 1200    # 設置網卡隊列長度

# ip link set eth0 mtu 1400      # 設置網卡最大傳輸單元

# ip route show 或 ip route list  或   route -n  # 查看路由(網關)信息

# ip route add 192.168.4.0/24  via  192.168.0.254 dev eth0 # 設置192.168.4.0網段的網關為192.168.0.254,數據走eth0介面

# ip route add default via  192.168.0.254  dev eth0    # 設置默認網關為192.168.0.254

# ip route del 192.168.4.0/24    # 刪除192.168.4.0網段的網關

# ip route del default    # 刪除默認路由

#查看NDS伺服器地址,使用nslookup命令,輸入命令:

比如:nslookup www..com

❷ linux怎麼刪除網橋的ip地址

1、建立網橋
touch
/etc/sysconfig/network-scripts/ifcfg-br0
建立網橋配置文件ifcfg-br0
vi
/etc/sysconfig/network-scripts/ifcfg-br0
2、添加網卡到網橋
把eth0和eth1兩網卡添加到網橋中。
修改eth1網卡配置文件
vi
/etc/sysconfig/network-scripts/ifcfg-eth0
修改eth2網卡配置文件
vi
/etc/sysconfig/network-scripts/ifcfg-eth2
3.
重啟網路服務
service
network
restart

❸ Linux下ip addr和ifconfig增刪查虛擬ip

使用 虛擬ip最多的場景空搜可能是雙機 ,往往結合著keepalived使用。其實沒有雙機軟體也可以使用虛擬ip,下面介紹兩種方法ip addr和ifconfig進行增刪查虛擬ip。

增加虛擬ip :

ip addr add ip/netmask dev 網口名稱,比如ip addr add 192.168.88.0/24 dev eth0

查看虛擬ip : 

ip addr show device_name或ip addr | grep eth0

ip addr =ip a= ip add list 查看網卡的ip和mac等,即使網卡處於down狀態,也能顯示出網卡狀態,但是ifconfig查看就看不到。

刪除虛擬ip:

ip addr del ip/netmask dev 網口名稱,比如ip addr del 192.168.88.0/24  dev eth0

清空指定網卡的所有ip:

ip addr flush dev 介面

ip addr 操作時的注意事項:

說明:網卡配置的ip一般為Primary ip,虛擬ip一般為Secondary ip,當刪除Primary ip時Secondary ip也有可能同時被刪除。

先查看ipv4或ipv6相應網卡開啟提升參數promote_secondaries為1,當Primary ip被刪除後,它的第1個Secondary ip將繼承為Primary ip。

#  cat /etc/sysctl.conf  | grep promote_secondaries

net.ipv4.conf.eth0.promote_secondaries=1

默認不開啟,查不到結果則表明未開啟。

Secondary ip和Primary ip標注如下

[root@localhost ~]# ip addr show eth0

2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000

    link/ether 00:19:b9:ef:44:8b brd ff:ff:ff:ff:ff:ff

    # Primary ip

    inet 172.16.0.230/24 brd 172.16.0.255 scope global eth0

    inet 10.1.1.230/24 scope global eth0

    # Secondary ip

    inet 10.1.1.231/24 scope global secondary eth0

在linux中在一個網卡上配置的同一個網段的ip有Primary IP和Secondary address之分,如果不是同一個網段的ip總有一個是Primary IP,一條鏈上的吊鏈結構中上面的那條主鏈中的IP是Primary IP,Secondary address是主鏈結點的子鏈結點中的IP,一 旦主鏈上一個節點被刪除斗嫌歷了,那麼它的子鏈也將不復存在,隨之被刪除。

可以通過調整一個參數來實現,當一個primary ip被刪除時,如果它有secondary ip的話,那麼它的第1個secondary地址(長子)成為primary地址,這樣就顯得很合理了,要不然在刪除 primary地址的時候,如果有程序用secondary地址,要麼延遲刪除,要麼程序崩者雀潰。

開啟的方法(主機重啟後仍然生效的)

echo "net.ipv4.conf.eth0.promote_secondaries=1" >>/etc/sysctl.conf

ifconfig eth1:1 192.168.5.10/24  up:起別名

ifconfig eth0:1 192.168.8.5 netmask 255.255.255.0 up

ifconfig eth1:1 192.168.5.10/24 down : 刪別名

ifconfig eth0:1 192.168.8.5 netmask 255.255.255.0 down

ifconfig eth1 up :啟用eth1網卡

ifconfig eth1 down : 禁用eth1網卡,這種禁用是從數據鏈路層斷掉,但是網路層ip還在,有時候能ping 通,大概率是緩存表沒有更新

ifdown eth0 : 禁用網卡,刪除了網路層ip

二者本質上沒有什麼區別,只是表述方式不同。如果你非常理解網路協議的原理以及網路的分層架構那麼我想你就不會有這個問題,實際上 每一個網卡設備都有一個mac地址 , 但是卻可以有多個網路層地址 ,比如IP地址,然而這個事實無法很好地像用戶提供操作介面,所以就引出了ip別名(IP aliases)和輔助ip(secondary IP addresses)的概念。其實很容易理解這個事實,按照分層的思想,下層總是為上層服務,也就是為上層提供舞台,上層利用下層的服務,而不必讓下層知道自己的情況,如果一個擁有合理mac地址的網卡沒有配置網路層地址(比如IP地址)這件事合理的話,那麼為這個設備配置多個IP地址也是合理的,好比一個ip可以對應多個應用層埠一樣,也就是說,下層對上層總是一對多的關系,在分層架構中這種關系是合理的。

比如一台機器上運行著一個代理伺服器或者負載均衡服務,代理伺服器或者負載均衡服務和主伺服器要監聽相同的埠,那麼就可以用secondary ip來解決,只要需要在同一網段監聽同一個埠的應用都是吊鏈中子鏈存在的原因,因此可以說,主鏈對外部或者說對下面鏈路層虛擬了多塊網卡, 而子鏈向上層虛擬了多台機器,配置了吊鏈結構的linux主機如果說只有一塊網卡,那麼外部會認為它有多塊網卡,對於內部,應用層會認為彼此在不同的主機 上,這就是效果。

添加地址可以通過2個用戶空間程序搞定,一個是ifconfig,另一個是ip addr add,ifconfig是基於ioctl進行添加地址的,而ip是基於netlink進行添加地址的,不管哪一種方式都可以達到目的。 但為何用ip addr add添加的ip地址用ifconfig看不到,而ifconfig設置的地址ip addr show卻是可以看到?這個問題先放一放。

ip addr增加的虛擬ip在物理主機或虛擬機重啟後失效。

方法1:把命令加到/etc/rc.local裡面

ip addr add 192.168.26.74/32 dev eth1

方法2:高可用雙機倒換後進行虛擬ip的增加

方法3:在/etc/sysconfig/network-scripts添加網卡名字,比如ifcfg-eth0:0,DEVICE=eth0:1 ---->子介面名

ONBOOT=yes

BOOTPROTO=static

IPADDR=192.168.109.108

NETMASK=255.255.255.0

ip addr 操作ip時需要注意

ip addr和ifconfig的區別

❹ 用java語言怎麼修改linux下eth0網卡的ip地址,請高手指點下,最好有例子....

vi /etc/sysconfig/network-scripts/ifcfg-eth0

點擊i 成插入狀態
添加
IPADDR=ccc.ccc.vvv.bbb
按下esc
輸入:wq 回車結束(冒號也是要輸入的)
需要重啟服務才能設置成剛才的ip
命令 為
service network restart

那個我也是做java的
我到現在都沒聽過java可以改ip的
我只聽過有偵測IP啊 獲取ip。。這些
至於修改ip 我真沒聽過
你見過.net可以修改自己機子的ip的嘛。
我也沒見過

❺ linux中怎麼清除ip

修改IP永久生效按以下方法vi /etc/sysconfig/network-scripts/ifcfg-eth0(eth0,第一塊網卡,如果是第二塊則為eth1)
按如下修改ip
DEVICE=eth0(如果是第二塊剛為eth1)
BOOTPROTO=static
IPADDR=192.168.0.11(改成要設置的IP)
NETMASK=255.255.255.0 (子網掩碼)
GATEWAY=192.168.0.1(網關)
ONBOO=yes
然後
service network restart
IP地址生效,重啟系統後不變
如果是臨時修改IP重啟系統後恢復原始IP則用以下命令
ifconfig IP地址 netmask 子網掩碼

❻ 用shell怎麼在linux下修改eth0的ip地址

!#/bin/bash

ifconfig eth0 x.x.x.x netmask x.x.x.x up #立即生效

ipconf = "/etc/sysconfig/network-scripts/ifcfg-eth0"
echo "DEVICE=eth0" > $ipconf
echo "ONBOOT=yes" > $ipconf
echo "BOOTPROTO=static" > $ipconf
echo "IPADDR=192.168.0.117" > $ipconf
echo "NETMASK=255.255.255.0" > $ipconf
echo "GATEWAY=192.168.0.254" > $ipconf
echo "service network restart" > $ipconf

❼ ifconfig配置ip

一、ifconfig與IP
1、ifconfig添加或修改原IP
ifconfig eth0 192.168.10.199 或
ifconfig eth0 192.168.10.199 netmask 255.255.255.0 up
ifconfig eth0:1 192.168.10.198 netmask 255.255.255.0 up

註:以上兩台效果是一樣的,上面一種寫法是下面一種寫法的減縮版。如果eth0上之前已經配置這IP,該配置會將原來的IP清掉,換成上面配置的IP,但在遠程ssh時最好不要使用該方法,因為網路環境不同。一旦更改不生效,就要跑到機房再進行配置。
2、禁用啟用網卡
ifconfig eth0 down
ifconfig eth0 up

該用法,是不是和ifup eth0、ifdown eth0:1很像?
註:當一塊網卡上配置多個IP時,如eth0、eth0:1時,如果禁掉eth0:1時,eth0上的網卡配置依然生效。但禁掉直接物理網卡口時(即eth0)時,其後面配置的IP (eth0:1等)都將被刪除掉。另外,ifconfig 還可以用於設置mtu和設置網卡的混雜模式:
ifconfig eth0 mtu 1472
利用netstat -i查看
將eth0設置成混雜模式
ifconfig eth0 promisc
取消混雜
ifconfig eth0 -promisc

3、修改網卡mac地址:
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

ifconfig查看的信息里,經常被我們忽視的第三行非常有用,如在沒有mii-tool工具時,可以通過其查看網卡連接狀態。
UP(代表網卡開啟狀態)RUNNING(代表網卡的網線被接上)MULTICAST(支持組播)MTU:1500(最大傳輸單元):1500位元組
二、ip命令與IP
ip是iproute2軟體包裡面的一個強大的網路配置工具,它能夠替代一些傳統的網路管理工具,例如ifconfig、route等,使用許可權為超級用戶。
1、ip命令添加一個IP地址:
[root@localhost ~]# ip addr add 192.168.10.198/24 dev eth0:1
[root@localhost ~]# ip addr add 192.168.10.199/24 dev eth0
[root@localhost ~]# ip -f inet addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
inet 192.168.10.26/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.198/24 scope global secondary eth0
inet 192.168.10.199/24 scope global secondary eth0
[root@localhost ~]# ip addr add 192.168.10.200/24 dev eth0:3
[root@localhost ~]# ip -f inet addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
inet 192.168.10.26/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.198/24 scope global secondary eth0
inet 192.168.10.199/24 scope global secondary eth0
inet 192.168.10.200/24 scope global secondary eth0

當然,上面的增加地址的寫法,我們也可以使用以下兩種方式增加,不過由於沒有上面的寫法容易記,我平時很少會用下面的方式增加:
ip addr add local 192.168.4.1/28 brd + label eth0:1 dev eth0
ip addr add 192.168.4.2/24 brd + dev eth1 label eth1:1

由上面的操作命令不難看出,隨便我們怎麼去添加IP,後面的設備名無論是eth0、eth0:1、eth0:100也好,其都不會將原網卡上綁定的地址給清掉。其通過ip addr show 顯示的出的結果都是secondary eth0 。
註:ip addr命令增加的IP ,不能通過ifconfig查看到,也不能通過ifconfig eth0:1 down 或ifdown eth0:1 這樣的方式停掉。
2、ip命令刪除一個IP
[root@localhost ~]# ip addr del 192.168.10.200
Not enough information: "dev" argument is required.
[root@localhost ~]# ip addr del 192.168.10.200 dev eth0
Warning: Executing wildcard deletion to stay compatible with old scripts.
Explicitly specify the prefix length (192.168.10.200/32) to avoid this warning.
This special behaviour is likely to disappear in further releases,
fix your scripts!
[root@localhost ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 40:61:86:98:95:05 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.26/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.198/24 scope global secondary eth0
inet 192.168.10.199/24 scope global secondary eth0
inet6 fe80::4261:86ff:fe98:9505/64 scope link
valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
[root@localhost ~]# ip addr del 192.168.10.199/24 dev eth0

在不加掩碼刪除時,其會提示警告,但還是可以將其地址刪掉。ip命令的用法比較多,就不一一列舉了。
三、路由配置
增加路由

route add -net 192.168.6.0/24 gw 192.168.101.254
route add default gw 192.168.101.254

查看路由
ip route list
route –n
netstat –r

四、總結
以上的ifconfig和ip命令配置的信息,重啟都會清除,想要永久生效,還是配置相關的配置文件。不過掌握命令配置方法很重要,在LVS+keepalive等架構上,浮動IP的變動,很多都是通過ip命令來完成的。

❽ linux下如何刪除靜態路由條目/或者靜態路由的文件在哪個目錄下面

linux下靜態路由修改命令

方法一:

添加路由 route add -net 192.168.0.0/24 gw 192.168.0.1

route add -host 192.168.1.1 dev 192.168.0.1

刪除路由 route del -net 192.168.0.0/24 gw 192.168.0.1

add 增加路由 del 刪除路由 -net 設置到某個網段的路由 -host 設置到某台主機的路由 gw 出口網關 IP地址 dev 出口網關 物理設備名
增加默認路由
route add default gw 192.168.0.1 默認路由一條就夠了
route -n 查看路由表
方法二:

添加路由 ip route add 192.168.0.0/24 via 192.168.0.1

ip route add 192.168.1.1 dev 192.168.0.1

刪除路由 ip route del 192.168.0.0/24 via 192.168.0.1

add 增加路由 del 刪除路由 via 網關出口 IP地址 dev 網關出口 物理設備名
增加默認路由 ip route add default via 192.168.0.1 dev eth0 via 192.168.0.1 是我的默認路由器

查看路由信息 ip route
保存路由設置,使其在網路重啟後任然有效 在/etc/sysconfig/network-script/目錄下創建名為route-eth0的文件 vi /etc/sysconfig/network-script/route-eth0 在此文件添加如下格式的內容
192.168.1.0/24 via 192.168.0.1
重啟網路驗證

/etc/rc.d/init.d/network中有這么幾行:
#
Add non interface-specific static-routes. if [ -f
/etc/sysconfig/static-routes ]; then grep "^any"
/etc/sysconfig/static-routes | while read ignore args ; do
/sbin/route add -$args done fi
也就是說,將靜態路由加到/etc/sysconfig/static-routes 文件中就行了。

如加入: route add -net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1
則static-routes的格式為 any net 11.1.1.0 netmask 255.255.255.0 gw 11.1.1.1

熱點內容
比特幣意外丟失 發布:2025-06-24 12:42:25 瀏覽:400
2011年中國比特幣價格是多少錢 發布:2025-06-24 12:38:34 瀏覽:860
比特幣區塊鏈的技術原理 發布:2025-06-24 12:33:39 瀏覽:217
芯動a9礦機安裝上機教程 發布:2025-06-24 12:28:23 瀏覽:131
比特幣和usdt哪個好 發布:2025-06-24 12:27:48 瀏覽:554
一圈嘉禾圍著半圓兩字是什麼幣 發布:2025-06-24 12:21:43 瀏覽:687
第一家區塊鏈公司 發布:2025-06-24 12:16:08 瀏覽:156
usdt洗幣流程 發布:2025-06-24 12:15:13 瀏覽:637
以太坊職能合約 發布:2025-06-24 12:05:19 瀏覽:976
幣圈媒體被封 發布:2025-06-24 11:51:58 瀏覽:295