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:
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.
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.
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
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.
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.