Failed set static IP of USB to network device

When I try to set static ip address of the usb to network connector device, the network device name is enp0s20f0u2u3,and i try to modify /etc/sysconfig/network-scripts/ifcfg-enp0s20f0u2u3,but there is no this file found, so a create a new file with this name , and add something as blow:

TYPE=Ethernet
BOOTPROTO=static
NAME=enp0s20f0u2u3
DEVICE=enp0s20f0u2u3
ONBOOT=no
HWADDR=00:e0:4c:36:28:02
IPADDR=192.168.100.200
GATEWAY=192.168.100.1

Then i do service NetworkManager restart command,after that i input the command ifconfig,the ip still not modified as 192.168.100.1 ?
the kernel version is Linux red.WS 5.6.13-300.fc32.x86_64 #1 SMP Thu May 14 22:51:37 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

The 192.168.100.1 address is set as your Gateway, not the device’s IPv4 address. The device itself should have an IP Address of 192.168.100.200 per your IFCFG file.

What is the output of the following?

$ ip a

Hello @iysheng
But are you on an headless machine, I mean, aren’t you using a graphical interface?
However I’m not sure, but nowadays /etc/sysconfig/network-scripts is not the way to configure network interfaces. You should have a look to the command nmcli

Scripts are stored within /etc/sysconfig/network-scripts regardless of whether they are created with nmcli or by hand. If creating them by hand, and as long as the syntax is correct, they should function just fine.

Additionally, if a script is modified, it should be reloaded with:

$ sudo nmcli con load /etc/sysconfig/network-scripts/ifcfg-<name>
Or:
$ sudo nmcli con reload <- This reloads all scripts.

Or, you could simply restart the NetworkManager service, which is what happened here.

When a system is booted, two things will take place with ifcfg scripts. The first is that NetworkManager (if installed and enabled) will try and bring whatever device online that it can. It does this by executing a nmcli con load on specific ifcfg scripts. The second is that /etc/init.d/network will dig through each ifcfg script, check to see if ONBOOT=yes exists and bring it up if NetworkManager hasn’t already.

Edit:

In this post, it simply sounds like there may be some confusion about the GATEWAY and IPADDR options. The GATEWAY option simply designates which IP Address all traffic should be routed through for that specific interface and the IPADDR sets the IP Address of the specific interface.

1 Like

I’m sorry, it’s my misspelling,i don’t get the ip 192.168.100.200;
the output of ip as below:

    link/ether 00:e0:4c:36:28:02 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5587:64e1:1412:2942/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

besides as i do

sudo nmcli connection load /etc/sysconfig/network-scripts/ifcfg-enp0s20f0u2u3

i get nothing output.i check the ip of enp0s20f0u2u3,it still no change.

Could you provide the output of this command?
nmcli con show

sure.

NAME                UUID                                  TYPE      DEVICE 
HUAWEI MATE 10 PRO  9e26cb41-9196-4f81-9aac-2ec7fa36b81d  wifi      wlp4s0 
9908                d0ceabd9-0cc7-4934-9100-137d1875c8e6  wifi      --     
aWiFi-Free          34e3d56a-4446-4ee4-88ae-081effa9bd2b  wifi      --     
enp0s20f0u2u3       4b2f33e5-a6ec-e994-fe09-5b91073a3b1a  ethernet  --     
Wired connection 1  dfddccee-c7b8-3952-944c-178393f0202c  ethernet  --     
Wired connection 2  3d8d2382-88bd-3b6c-b01c-5c8432a17dbb  ethernet  --     

After I do command

sudo nmcli connection load /etc/sysconfig/network-scripts/ifcfg-enp0s20f0u2u3

then i do nmcli con show again

NAME                UUID                                  TYPE      DEVICE 
HUAWEI MATE 10 PRO  9e26cb41-9196-4f81-9aac-2ec7fa36b81d  wifi      wlp4s0 
9908                d0ceabd9-0cc7-4934-9100-137d1875c8e6  wifi      --     
aWiFi-Free          34e3d56a-4446-4ee4-88ae-081effa9bd2b  wifi      --     
enp0s20f0u2u3       4b2f33e5-a6ec-e994-fe09-5b91073a3b1a  ethernet  --     
Wired connection 1  dfddccee-c7b8-3952-944c-178393f0202c  ethernet  --     
Wired connection 2  3d8d2382-88bd-3b6c-b01c-5c8432a17dbb  ethernet  --     

And if you issue this command?
sudo nmcli con up enp0s20f0u2u3

I success do this command sudo nmcli con up enp0s20f0u2u3, after i do that the net device ip setted with 192.168.100.100.but why sudo service NetworkManager restart could not do this ??
Besides, I found a another issue, I both have wifi and the (usb to netcable) device , I use wifi to surfing on net, use the usb to netcable to debug the embeded device, but after do this command ,i could not surfing,when i do

ping 8.8.8.8
From 192.168.100.200 icmp_seq=1 Destination Host Unreachable

I think that the point is

In this case the point is the gateway. You have 2 connections. Each one has configured a default gateway. Ethernet connection takes the precedence when started, but the default gateway is unreachable.

Try to remove this

thanks,you are right, now I can surfing by remove the line GATEWAY=192.168.100.1 and both sudo service NetworkManager restart can set the netcable static ip by change the line ONBOOT=yes. :+1:

2 Likes