Setting static IP and gateway



Hi,

Having loads of problems when trying to set a new system that was set up to use DHCP to now use a static ip 
and gateway. I’ve done lots of searches and the vast majority of it appears to be around setting up a new 
connection or completely disabling NetworkManager.

I’ve the following interface: eno16777736

The IP is currently: 

[root server ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:9a:2a:7b brd ff:ff:ff:ff:ff:ff
    inet 192.168.115.133/24 brd 192.168.115.255 scope global dynamic eno16777736
    inet6 fe80::20c:29ff:fe9a:2a7b/64 scope link 
       valid_lft forever preferred_lft forever
[root server ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.115.2   0.0.0.0         UG    1024   0        0 eno16777736
192.168.115.0   0.0.0.0         255.255.255.0   U     0      0        0 eno16777736
[root server ~]# 

Interface currently set by DHCP:

[root server ~]# nmcli con sho eno16777736 | grep -i ipv4
ipv4.method:                            auto
ipv4.dns:                               
ipv4.dns-search:                        
ipv4.addresses:                         
ipv4.routes:                            
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
[root server ~]# 

I try and set the gateway several ways:

[root server ~]# nmcli con mod eno16777736 ipv4.method manual ipv4.addresses 192.168.115.133/24, 192.168.115.2
Error: value for '192.168.115.2' is missing.
[root server ~]# nmcli con mod eno16777736 ipv4.method manual ipv4.addresses 192.168.115.133/24, gw 
192.168.115.2
Error: invalid <setting>.<property> 'gw'.
[root server ~]# nmcli con mod eno16777736 ipv4.method manual ipv4.addresses 192.168.115.133/24, ipv4.gw 
192.168.115.2
Error: invalid property 'gw': 'gw' not among [method, dns, dns-search, addresses, address-labels, routes, 
ignore-auto-routes, ignore-auto-dns, dhcp-client-id, dhcp-send-hostname, dhcp-hostname, never-default, 
may-fail].
[root server ~]# 

If I leave the gateway out, then it sets, but the default gateway gets wiped.

[root server ~]# nmcli con mod eno16777736 ipv4.method manual ipv4.addresses 192.168.115.133/24
[root server ~]# nmcli con sho eno16777736 | grep -i ipv4
ipv4.method:                            manual
ipv4.dns:                               
ipv4.dns-search:                        
ipv4.addresses:                         { ip = 192.168.115.133/24, gw = 0.0.0.0 }
ipv4.routes:                            
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
[root server ~]# ifdown eno16777736; ifup eno16777736
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)
[root server ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.115.0   0.0.0.0         255.255.255.0   U     0      0        0 eno16777736
[root server ~]# 

So, how do you set the default route when changing from DHCP to static IP’s?

Many thanks,

- Colin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]