# How to use Static IP?

## Solour

Hi there,

I was assigned a static IP but I have no clue how to use it. :-/

I am connecting to the local VPN server using a cable-socket in the wall.

That is, i am using DHCP to get an IP and then I am establishing a VPN connection to get access to the internet.

Now I was told that this socket was assigned a static IP.

But I have no clue what I need to change...

It should be much simpler but I have no clue how to configure that...

Please help me!

What information about my system is important for this issue?

Cheers.

----------

## Tal_Sar

I would say you should figure out which ip you got assigend.

After that you can use this command:

```
net-setup eth0 
```

i think eth0 will be ok. But it could be that you are using another intefrace like eth1, eth2,... so you have to change this

i hope this helps  :Wink: 

----------

## gerdesj

 *Solour wrote:*   

> 
> 
> I am connecting to the local VPN server using a cable-socket in the wall.
> 
> That is, i am using DHCP to get an IP and then I am establishing a VPN connection to get access to the internet.
> ...

 

Not much in the way of details here  :Cool: 

I do not understand your reference to a VPN server.  Do you mean your ISP?

If you have been assigned a static IP address then quite often that can be delivered to you by DHCP - you just get the same address all the time.  If that is the case then there is nothing for you to do.

If it is not DHCP assigned then you will have to edit /etc/conf.d/net.  There are notes on what to put in there in /etc/conf.d/net.example and the Gentoo website link to documentation gives a lot of detail on networking - http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4

Assuming eth0 is your network card:

# /etc/conf.d/net

config_eth0=( "123.456.789.123/30" )

routes_eth0=( "default via 123.456.789.124" )

The correct addresses to put in net will be assigned for you but if you have to configure this yourself, you need to know your next hop ie default gateway.

You might be able to get these details by (make sure iproute2 is installed) and run:

#ip a

#ip r

These will give you the addresses and routing table in use on your system.

Cheers

Jon

Cheers

Jon

----------

## Solour

Thank you very much!

It is working  :Smile: 

However, suddenly my ntp-client does not work any more...

```
cat  /etc/conf.d/ntp-client

# /etc/conf.d/ntp-client

# Command to run to set the clock initially

# Most people should just leave this line alone ...

# however, if you know what you're doing, and you

# want to use ntpd to set the clock, change this to 'ntpd'

NTPCLIENT_CMD="ntpdate"

# Options to pass to the above command

# This default setting should work fine but you should

# change the default 'pool.ntp.org' to something closer

# to your machine.  See http://www.pool.ntp.org/ or

# try running `netselect -s 3 pool.ntp.org`.

NTPCLIENT_OPTS="-s -b -u \

        0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org \

        2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org"

# /etc/init.d/ntp-client restart

 * Setting clock via the NTP client 'ntpdate' ...

 * Failed to set clock

```

probably my /etc/ntp.conf was used which was previously created when I executed dhclient...

As you can see I am not getting much information there...

Currently I can establish my old vpn connection, execute /etc/init.d/ntp-client start and then connect using the static IP.

I really hope you can help me here...

Cheers

ps: I am not getting the IP assigned via DHCP.

----------

## cwr

Try running "ifconfig  -a" once you've got your VPN connection established.

That should give you some idea of where your packets are going; then

pinging the ntp servers you use should give you more ideas.

Will

----------

## Solour

I do not see how to read this output….

initially (before connecting) I got this

```
eth0      Link encap:Ethernet  HWaddr 00:21:9b:df:4e:1a

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

          Interrupt:16

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:108 errors:0 dropped:0 overruns:0 frame:0

          TX packets:108 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:8948 (8.7 KiB)  TX bytes:8948 (8.7 KiB)

sit0      Link encap:IPv6-in-IPv4

          NOARP  MTU:1480  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
```

when connected using vpn I get

```
eth0      Link encap:Ethernet  HWaddr 00:21:9b:df:4e:1a

          inet addr:192.168.***.***  Bcast:192.168.23.255  Mask:255.255.252.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1255 errors:0 dropped:0 overruns:0 frame:0

          TX packets:419 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:164244 (160.3 KiB)  TX bytes:49165 (48.0 KiB)

          Interrupt:16

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:84 errors:0 dropped:0 overruns:0 frame:0

          TX packets:84 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:6744 (6.5 KiB)  TX bytes:6744 (6.5 KiB)

ppp0      Link encap:Point-to-Point Protocol

          inet addr:130.149.***.***  P-t-P:130.149.145.8  Mask:255.255.255.255

          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1456  Metric:1

          RX packets:326 errors:0 dropped:0 overruns:0 frame:0

          TX packets:336 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:3

          RX bytes:92930 (90.7 KiB)  TX bytes:25782 (25.1 KiB)

sit0      Link encap:IPv6-in-IPv4

          NOARP  MTU:1480  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
```

when connected using the static IP I get

```
eth0      Link encap:Ethernet  HWaddr 00:21:9b:df:4e:1a

          inet addr:130.149.***.***  Bcast:130.149.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:477 errors:0 dropped:0 overruns:0 frame:0

          TX packets:218 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:86889 (84.8 KiB)  TX bytes:20148 (19.6 KiB)

          Interrupt:16

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:127 errors:0 dropped:0 overruns:0 frame:0

          TX packets:127 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:10667 (10.4 KiB)  TX bytes:10667 (10.4 KiB)

sit0      Link encap:IPv6-in-IPv4

          NOARP  MTU:1480  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
```

This time I rebooted before connecting using the static IP...

Probably it has to do with using the ppp0 interface instead of eth0 when using vpn?

Just a wild guess...

All servers in my /etc/conf.d/ntp-client can be ping'ed successfully...

They are 0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org and 3.gentoo.pool.ntp.org

----------

## cwr

Ok, if the servers can be pinged then it's pretty certain that ntp is getting the

time, so the problem is with the local clock setting.  Ntp won't set a clock if

the time change is over a specific limit (and I can't recall the limit).  You

need to check your clock's time, and ntp's man pages, to see how to get around

the problem.

Will

----------

## Solour

When executing ntpdate directly I get a difference.. however, I guess it is still some routing problem...?

When connecting using static IP I get:

```
ntpdate -s -b -u -d 3.gentoo.pool.ntp.org
```

```
transmit(85.214.111.97)

transmit(88.84.153.170)                               

transmit(213.198.55.2)                                

transmit(85.214.111.97)                               

transmit(88.84.153.170)                               

transmit(213.198.55.2)                                

transmit(85.214.111.97)                               

transmit(88.84.153.170)                               

transmit(213.198.55.2)                                

transmit(85.214.111.97)                               

transmit(88.84.153.170)                               

transmit(213.198.55.2)                                

transmit(85.214.111.97)                               

transmit(88.84.153.170)                               

transmit(213.198.55.2)                                

85.214.111.97: Server dropped: no data                

88.84.153.170: Server dropped: no data                

213.198.55.2: Server dropped: no data                 

server 85.214.111.97, port 123                        

stratum 0, precision 0, leap 00, trust 000            

refid [85.214.111.97], delay 0.00000, dispersion 64.00000

transmitted 4, in filter 4                               

reference time:    00000000.00000000  Thu, Feb  7 2036  7:28:16.000

originate timestamp: 00000000.00000000  Thu, Feb  7 2036  7:28:16.000

transmit timestamp:  cf1523ac.ee1cef24  Thu, Feb  4 2010 11:45:00.930

filter delay:  0.00000  0.00000  0.00000  0.00000                    

         0.00000  0.00000  0.00000  0.00000                          

filter offset: 0.000000 0.000000 0.000000 0.000000                   

         0.000000 0.000000 0.000000 0.000000                         

delay 0.00000, dispersion 64.00000                                   

offset 0.000000                                                      

server 88.84.153.170, port 123

stratum 0, precision 0, leap 00, trust 000

refid [88.84.153.170], delay 0.00000, dispersion 64.00000

transmitted 4, in filter 4                               

reference time:    00000000.00000000  Thu, Feb  7 2036  7:28:16.000

originate timestamp: 00000000.00000000  Thu, Feb  7 2036  7:28:16.000

transmit timestamp:  cf1523ad.215592d9  Thu, Feb  4 2010 11:45:01.130

filter delay:  0.00000  0.00000  0.00000  0.00000                    

         0.00000  0.00000  0.00000  0.00000                          

filter offset: 0.000000 0.000000 0.000000 0.000000                   

         0.000000 0.000000 0.000000 0.000000                         

delay 0.00000, dispersion 64.00000                                   

offset 0.000000                                                      

server 213.198.55.2, port 123

stratum 0, precision 0, leap 00, trust 000

refid [213.198.55.2], delay 0.00000, dispersion 64.00000

transmitted 4, in filter 4                              

reference time:    00000000.00000000  Thu, Feb  7 2036  7:28:16.000

originate timestamp: 00000000.00000000  Thu, Feb  7 2036  7:28:16.000

transmit timestamp:  cf1523ad.548344c3  Thu, Feb  4 2010 11:45:01.330

filter delay:  0.00000  0.00000  0.00000  0.00000                    

         0.00000  0.00000  0.00000  0.00000                          

filter offset: 0.000000 0.000000 0.000000 0.000000                   

         0.000000 0.000000 0.000000 0.000000                         

delay 0.00000, dispersion 64.00000                                   

offset 0.000000
```

When connecting using VPN I get:

```
ntpdate -s -b -u -d 3.gentoo.pool.ntp.org
```

```
transmit(213.198.55.2)                                                                  

receive(213.198.55.2)

transmit(213.198.55.2)

receive(213.198.55.2)

transmit(213.198.55.2)

receive(213.198.55.2)

transmit(213.198.55.2)

receive(213.198.55.2)

transmit(213.198.55.2)

transmit(213.239.205.46)

receive(213.239.205.46)

transmit(213.239.205.46)

receive(213.239.205.46)

transmit(213.239.205.46)

receive(213.239.205.46)

transmit(213.239.205.46)

receive(213.239.205.46)

transmit(213.239.205.46)

transmit(78.46.194.185)

transmit(78.46.194.185)

receive(78.46.194.185)

transmit(78.46.194.185)

receive(78.46.194.185)

transmit(78.46.194.185)

receive(78.46.194.185)

transmit(78.46.194.185)

server 213.198.55.2, port 123

stratum 2, precision -20, leap 00, trust 000

refid [213.198.55.2], delay 0.04732, dispersion 0.00023

transmitted 4, in filter 4

reference time:    cf150e01.cbbd1205  Thu, Feb  4 2010 10:12:33.795

originate timestamp: cf150f9b.2fad8923  Thu, Feb  4 2010 10:19:23.186

transmit timestamp:  cf1524bb.517fb699  Thu, Feb  4 2010 11:49:31.318

filter delay:  0.04919  0.04784  0.04808  0.04732

         0.00000  0.00000  0.00000  0.00000

filter offset: -5408.14 -5408.14 -5408.14 -5408.14

         0.000000 0.000000 0.000000 0.000000

delay 0.04732, dispersion 0.00023

offset -5408.142989

server 213.239.205.46, port 123

stratum 2, precision -20, leap 00, trust 000

refid [213.239.205.46], delay 0.04555, dispersion 0.00053

transmitted 4, in filter 4

reference time:    cf150db0.ac2dcaf8  Thu, Feb  4 2010 10:11:12.672

originate timestamp: cf150f9b.61bd2cba  Thu, Feb  4 2010 10:19:23.381

transmit timestamp:  cf1524bb.830caa32  Thu, Feb  4 2010 11:49:31.511

filter delay:  0.04649  0.04669  0.04555  0.05119

         0.00000  0.00000  0.00000  0.00000

filter offset: -5408.14 -5408.14 -5408.14 -5408.14

         0.000000 0.000000 0.000000 0.000000

delay 0.04555, dispersion 0.00053

offset -5408.143961

server 78.46.194.185, port 123

stratum 2, precision -19, leap 00, trust 000

refid [78.46.194.185], delay 0.04514, dispersion 8.00046

transmitted 4, in filter 4

reference time:    cf150c01.2389f4fc  Thu, Feb  4 2010 10:04:01.138

originate timestamp: cf150f9c.8ec64fe7  Thu, Feb  4 2010 10:19:24.557

transmit timestamp:  cf1524bc.b0bba12b  Thu, Feb  4 2010 11:49:32.690

filter delay:  0.00000  0.04662  0.04514  0.04659

         0.00000  0.00000  0.00000  0.00000

filter offset: 0.000000 -5408.14 -5408.14 -5408.14

         0.000000 0.000000 0.000000 0.000000

delay 0.04514, dispersion 8.00046

offset -5408.142604
```

----------

