Linux Set IP

You can setup a static IP manually without using the NetworkManager:

sudo vi /etc/NetworkManager/NetworkManager.conf

Edit NetworkManger.conf and set the value of "managed" under "ifupdown" to false:

[ifupdown]
managed=false

Add network setting to /etc/network/interfaces:

$ sudo vi /etc/network/interfaces

Here is is sample of /etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback
 
# network interface not managed by Network Manager
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.199
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1

 

4.2 2: Setup Static IP with NetworkManager

Here is an example demonstrating how to setup a static IP with NetworkManager in a wired network
Check netowrk connection:

pi@Smart4418SDK:~$ sudo nmcli connection show
NAME                UUID                                  TYPE            DEVICE 
Wired connection 1  cffa785e-0425-3777-b670-092c79328a1f  802-3-ethernet  eth0

The above messages show that there is a wired connection named "Wired connection 1". You can set a static IP for "Wired connection 1" by running the following commands:

sudo nmcli connection modify 'Wired connection 1' connection.autoconnect yes ipv4.method manual ipv4.address 192.168.2.199/24 ipv4.gateway 192.168.2.1 ipv4.dns 192.168.2.1
sudo reboot

If this is successful the connection will be assigned a static IP with IP address to be 192.168.2.199 and both gateway and DNS to be 192.168.2.1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值